I am working on excel macro and got stuck at one point. Need help to please resolve it.
I have to look for 2 rows in sheet, and for each value in 1 row look for the cell value in 2 row. If the range of values in row 2 equal to some conditional value, then come out of the row 2 check and set the flag as true. For achieving this I used two For Each loop:
Sub Sendmail ()
For Each cell in Rows("5").Cells.SpecialCells(xlCellTypeConstant)
If cells.Value Like "*@*" Then
Subj = "Fill the Sheet"
Recipient = cell.Offset(0,-3).Value
EmailAddr = cell.Offset.Value
For Each row In Sheet14.Range("O244:AK244").Cells
If Not row = '8.00" Then
found = False
Else
found = True
End If
Next row
If found = False Then
Msg = "Hi " & Recipient & vbCrLf & vbCrLf
Msg = Msg & " Please fill the sheet for this week " & vbCrLf & vbCrLf
Set MItem = Outlook.CreateItem(oIMailItem)
With MItem
.To = EmailAddr
.Subject = Subj
.Body = Msg
.Save
End With
End If
End If
Next
End Sub
The found variable used here is defined as Boolean , but I am not able to use it properly, and every time found = false is executing . I want only once the condition is true for row 2, then only the mail should be created .