ItalianPlatinum
Well-known Member
- Joined
- Mar 23, 2017
- Messages
- 878
- Office Version
- 365
- 2019
- Platform
- Windows
I am looking for a line of code to stop my exiting code from running if it cannot find today's today in YYYYMMDD format in column B.
' Convert todays date to a number that looks like yyyymmdd
Dim d As Long
d = Format(Date, "yyyymmdd") + 0
' See if the current date is found anywhere in column B
If Application.WorksheetFunction.CountIf(Range("B:B"), d) > 0 Then
'whatever you want to happen here if the date is found in column B
End If
Dim d As Long
Application.ScreenUpdating = False
Application.EnableEvents = False
'set shortcut for with sheets
'set shortcut without "with"
'Use either workbook extension to avoid file extension option issue
d = Format(Date, "yyyymmdd") + 0
'check if any ex dates to evaluate if not end sub
If Application.WorksheetFunction.CountIf(Range("B:B"), d) = 0 Then
With WsRUN
.Activate
End With
MsgBox "No activity for Today"
Else
'if there are dates run other code