Hi! guys I'm new with VBA code.
Firstly, My native language is not English so may be it look weird in some word.
I do some alert when the date will approaching deadline by VBA code into outlooks .
And I want to skip all blank cell in the loop to alert only the cell with the date.
But I don't know the code to skip them and where to place them in my code.
Hope , I explain this clearly for you all.
Many Thanks!
Firstly, My native language is not English so may be it look weird in some word.
I do some alert when the date will approaching deadline by VBA code into outlooks .
And I want to skip all blank cell in the loop to alert only the cell with the date.
But I don't know the code to skip them and where to place them in my code.
Hope , I explain this clearly for you all.
Many Thanks!
VBA Code:
Sub InvoiceAlert()
Set tbl = ActiveSheet.ListObjects("ProjectTable")
Dim EmailApp As Outlook.Application
Set EmailApp = New Outlook.Application
Dim EmailItem As Outlook.MailItem
Set EmailItem = EmailApp.CreateItem(olMailItem)
'get current date
DateToday = Date
'check number of rows
NumRows = tbl.DataBodyRange.Rows.Count
'set day to noti
NumDayNoti = Range("T2")
CountPreNoti = 0
For i = 1 To NumRows
projInvoiceDate = tbl.DataBodyRange.Cells(i, tbl.ListColumns("InvoiceDate").Index)
projInvoiceFinish = tbl.DataBodyRange.Cells(i, tbl.ListColumns("InvoiceFinish").Index)
If projInvoiceFinish <> "DONE" And (projInvoiceDate - NumDayNoti) <= DateToday Then
PreNotiMsg = PreNotiMsg & GetTableData(i) & "<br>"
CountPreNoti = CountPreNoti + 1
End If
Next i
If CountPreNoti > 0 Then
'E-mail that need to send and CC.
EmailItem.To = " e-mail"
EmailItem.CC = " e-mail"
'E-mail Subject.
EmailItem.Subject = "Invoice Deadline is approaching soon"
'E-mail body.
EmailItem.HTMLBody = _
"Dear All," & _
"<br><br>" & _
"follow invoice soon." & _
"<br>" & _
" __________________________________________________________________________________" & _
"<br><br>" & _
" INVOICE DATE IS APPROACHING : " & CountPreNoti & " items " & _
"<br><br>" & _
PreNotiMsg & _
"<br><br>" & _
"Please check and update the file" & _
"<br>" & _
dHyperlink & _
"<br><br>" & _
"This E-mail generated by Excel VBA." & _
"<br>" & _
"Thank you,"
EmailItem.Display
End If
End Sub