Excel VBA - compare date in cell to current date
问题 (Excel 2010 VBA) I have a cell (A1) containing a date in the format of mmm-yy ("Custom" category). Foe example, if I enter 1/6/13 the cell shows June-13. That's fine. In my VB macro I need to check this date whether the month is the current month and whether the year is the current year. I don't care about the day. 回答1: Does this help you: Public Sub test() d = Sheet1.Range("A1") n = Now() If Year(d) = Year(n) And Month(d) = Month(n) Then MsgBox "It works" End If End Sub 回答2: Thanks to Dave