Hi I have several dates in column L
Day/date/month/year
Before executing a specific code, what is required is to verify that there is at least one month that corresponds to cell K2, which contains the name of the month only. If it is not found, the execution of the macro is canceled. I tried this, but it does not respond.
Day/date/month/year
Before executing a specific code, what is required is to verify that there is at least one month that corresponds to cell K2, which contains the name of the month only. If it is not found, the execution of the macro is canceled. I tried this, but it does not respond.
VBA Code:
Sub example()
Set ws = ActiveSheet
Dim StartDate As Range
Dim rgFound As Range
lastrow = ws.Range("L" & Rows.Count).End(xlUp).Row
Set StartDate = ws.Range("k2")
Set rgFound = Range("L1:l" & lastrow).Find(What:=Month(StartDate), LookAt:=xlWhole, LookIn:=xlValues)
If rgFound Is Nothing Then
MsgBox "The date Not Found.", vbOKOnly + vbExclamation
Exit Sub
End If
'When checking for the same month
'Run macro
' ....................................
End Sub