Send emails if excel cells are blank with VBA

Viewed 54

There's a column that has to be completed manually everyday by people all around the world, sometimes someone forget to complete their slot so i want to write a VBA script that will check everyday if there are empty cells in that column if yes then it will send an email to the corresponding email adresse a few column to the right, here is what i have come up with so far.

Sub Test()

Dim rng1 As Range, myval As Range, rngeAddresses As Range
Dim aOutlook  As Object, aEmail As Object

Set rng1 = Range("L3:L131")

For Each myval In rng1
    
    If myval.Value = "" And myval.Offset(0, 27).Value <> "" Then
        Set aOutlook = CreateObject("Outlook.Application")
        Set aEmail = aOutlook.CreateItem(0)
        With aEmail
            .To = myval.Offset(0, 27).Value
            .CC = ""
            .BCC = ""
            .Subject = ""
            .Body = pBody
            .Display
            '.send
        End With
    
    End If
    
Next

    
End Sub

I am fairly new to VBA so any help is welcome, thank you in advance

0 Answers
Related