mattmcclements
New Member
- Joined
- Apr 15, 2022
- Messages
- 36
- Office Version
- 2016
- Platform
- Windows
Hi all,
My spreadsheet runs from imports that will then generate an email if the instance is met (J>=3). I have this code which I want to scan the sheet for said instances once the information is imported but it doesn't seem to be working.
Sub Check_Offences()
Dim MailAddress As String
Dim MailAddress_CC As String
Dim ByDate As String
DimLr As Long
Dim r As Long
On Error Resume Next
With Sheets("Lates")
'Get last row
Lr = .Range("A" & .Rows.Count).End(xlUp).Row
For Each cell In .Range("J2:J" & Lr)
If IsNumeric(cell) And cell >= 3 And Not cell.Offset(0, 2) = "Y" Then '<<< Assumes 'Email Sent' Confirmation Y' ' in column L <<< ???(Offset 2)
r = cell.Row
MailAddress = .Range("M" & r).Value
MailAddress_CC = .Range("" & r).Value
'String of Date in C '??
ByDate = CDate(.Range("C" & r))
Call Mail_small_Text_Outlook(MailAddress, MailAddress_CC, ByDate) '<<<<<<
' Send the email
emailItem.Send
'Mark email as Sent in column L <<<< ?????
.Range("L" & r) = "Y"
Else
End If
Any help would be greatly appreciated.
My spreadsheet runs from imports that will then generate an email if the instance is met (J>=3). I have this code which I want to scan the sheet for said instances once the information is imported but it doesn't seem to be working.
Sub Check_Offences()
Dim MailAddress As String
Dim MailAddress_CC As String
Dim ByDate As String
DimLr As Long
Dim r As Long
On Error Resume Next
With Sheets("Lates")
'Get last row
Lr = .Range("A" & .Rows.Count).End(xlUp).Row
For Each cell In .Range("J2:J" & Lr)
If IsNumeric(cell) And cell >= 3 And Not cell.Offset(0, 2) = "Y" Then '<<< Assumes 'Email Sent' Confirmation Y' ' in column L <<< ???(Offset 2)
r = cell.Row
MailAddress = .Range("M" & r).Value
MailAddress_CC = .Range("" & r).Value
'String of Date in C '??
ByDate = CDate(.Range("C" & r))
Call Mail_small_Text_Outlook(MailAddress, MailAddress_CC, ByDate) '<<<<<<
' Send the email
emailItem.Send
'Mark email as Sent in column L <<<< ?????
.Range("L" & r) = "Y"
Else
End If
Any help would be greatly appreciated.