I currently have a code written to send and "Email_Notice" based on a value present condition for the last row of data entered. The data is transferred from a user form via a manual button macro. I am only wanting to execute this "Email_Notice" macro when the text value "Fail" is present in one of the multiple cells on the last row of data.
My current code will send the email when I manually start it as I do not have it configured to Loop yet but it will execute the "Email_Notice" sub whether or not "Fail" is within the data range. Can anyone tell me what I am doing wrong? (code below)
______________________________________________________________________________
Sub OOS_Finding()
'***File sends email when "Fail" is present in last row of recorded data. [Columns F-N]
On Error Resume Next
LastRow = Range ("A" & Rows.Count).End(xlUp).Row
Set Target = LastRow
If Target.Text = "Fail" Then Call Email_Notice
End Sub
_________________________________________________________________________________
Sub Email_Notice ()
'***Send Email to Identified Auditors When unit Fails Quality Check
Dim emailApplication As Object
Dim emailItem As Object
Set emailAppplication - CreateObject ("Outlook.Application")
Set emailItem - emailApplication.CreateItem(0)
emailItem.to - "user@email.com
emailItem.Subject = "Test"
emailItem.Body - "Quality Finding"
emailItem.Send
Set emailItem - Nothing
Set emailApplication - Nothing
End Sub
_______________________________________________________________________
My current code will send the email when I manually start it as I do not have it configured to Loop yet but it will execute the "Email_Notice" sub whether or not "Fail" is within the data range. Can anyone tell me what I am doing wrong? (code below)
______________________________________________________________________________
Sub OOS_Finding()
'***File sends email when "Fail" is present in last row of recorded data. [Columns F-N]
On Error Resume Next
LastRow = Range ("A" & Rows.Count).End(xlUp).Row
Set Target = LastRow
If Target.Text = "Fail" Then Call Email_Notice
End Sub
_________________________________________________________________________________
Sub Email_Notice ()
'***Send Email to Identified Auditors When unit Fails Quality Check
Dim emailApplication As Object
Dim emailItem As Object
Set emailAppplication - CreateObject ("Outlook.Application")
Set emailItem - emailApplication.CreateItem(0)
emailItem.to - "user@email.com
emailItem.Subject = "Test"
emailItem.Body - "Quality Finding"
emailItem.Send
Set emailItem - Nothing
Set emailApplication - Nothing
End Sub
_______________________________________________________________________