I need a script that reviews figures from top to bottom of the 3rd column and if it sees 0 and the digit before it is greater than 100 then the value of that digit is sent in the email header. The current version of coding sends all the values to the e-mail (the condition does not work). But if GoTo is replaced with Msgbox the script works perfectly...
For i = 2 To 100 Step 1
If cells(i, 3) = 0 And cells(i - 1, 3) < 100 Then Exit For
If cells(i, 3) = 0 And cells(i - 1, 3) > 100 Then GoTo email
If cells(i, 3) = 0 And cells(i - 1, 3) > 100 Then Exit For
Next i
email:
Dim olObj_1 As Outlook.Application
Dim mItem_1 As Outlook.MailItem
Set olObj_1 = New Outlook.Application
Set mItem_1 = olObj_1.CreateItem(olMailItem)
With mItem_1
.To = "xxxx@xxxx.com"
.Subject = "Figure_one " & cells(i - 1, 3)
.Send
End With
End Sub
Aucun commentaire:
Enregistrer un commentaire