I have never used VBA before until trying to learn to write this code. I am trying to look at the value in a specific cell (I2) and if it reads "Time to call" then I want it to send an email with specific text and values of additional cells in that row of data. Once I get the code to work in one row of data, I would like the code to then repeat itself through the entire worksheet. I currently have only about 250 lines but the worksheet will continue to grow. When I run my Macro I get the "Run-time error '1004': Application-defined or object define error". I cannot figure out where my mistake is and how to fix. Any help is appreciated.
Sub DataCheck()
If Range("I2").Value = "Time to call" Then Call FinalEmail
End Sub
Sub FinalEmail()
Dim emailApplication As Object
Dim emailItem As Object
Set emailApplication = CreateObject("Outlook.Application")
Set emailItem = emailApplication.CreateItem(0)
emailItem.to = "troy_hardin@zeeco.com"
emailItem.Subject = "Tickler File Alert"
emailItem.Body = "Contact" & vbNewLine & _
Range("A2+B2") & vbNewLine & _
"about their" & vbNewLine & _
Range("C2").Value
emailItem.display
Set emailItem = Nothing
Set emailApplication = Nothing
End Sub
Sub DataCheck()
If Range("I2").Value = "Time to call" Then Call FinalEmail
End Sub
Sub FinalEmail()
Dim emailApplication As Object
Dim emailItem As Object
Set emailApplication = CreateObject("Outlook.Application")
Set emailItem = emailApplication.CreateItem(0)
emailItem.to = "troy_hardin@zeeco.com"
emailItem.Subject = "Tickler File Alert"
emailItem.Body = "Contact" & vbNewLine & _
Range("A2+B2") & vbNewLine & _
"about their" & vbNewLine & _
Range("C2").Value
emailItem.display
Set emailItem = Nothing
Set emailApplication = Nothing
End Sub