I am trying to compare the date in an Excel cell (A1) to the current date using the now() function.
The date in cell A1 is dd/mm/yyyy. However the now() function returns dd/mm/yyyy HH:MM.
So when I compare dates the date is never the same as the now() function is considering HH:MM.
How can I compare only the dates? I have tried formatting the date to dd/mm/yyyy but that did not work.
Sub Macro6()
Dim currentDate As Date
currentDate = Now()
If Range("A1") = Format(currentDate, "dd/mm/yyyy") Then
MsgBox ("Date is not the same")
Else
MsgBox ("Date is the same")
End If
End Sub
Bookmarks