I'm trying to make a macro that checks every cell with data in row A, compares it to cell A1, and highlights it if their month doesn't match.
Issue is, the dates in these cells all follow the DD/MM/YYYY format. 01/08/2021, for example. And I don't know if the Date calls work with them, or how to approach this in the first place.
I've checked every thread I could, made a junction of everything useful I've found, and I've gotten this far:
Any help is appreciated!
Issue is, the dates in these cells all follow the DD/MM/YYYY format. 01/08/2021, for example. And I don't know if the Date calls work with them, or how to approach this in the first place.
I've checked every thread I could, made a junction of everything useful I've found, and I've gotten this far:
VBA Code:
Sub Test()
Dim AMonth As Integer
AMonth = Month(Cells(2, 1).Value)
Dim lRow As Long, Cel As Range, Data As Range, Brange As Range, BMonth As Integer
BMonth = ?
With ActiveSheet
lRow = .Cells(.Rows.Count, "A").End(xlUp).Row
Set Data = .Range("A1:A2" & lRow)
For Each Cel In Data
If Not BMonth = AMonth Then
If Not Brange Is Nothing Then Set Brange = Union(Brange, Cel) Else Set Brange = Cel
End If
Next Cel
Data.Interior.Color = xlNone
If Not Brange Is Nothing Then Brange.Interior.Color = RGB(255, 192, 0)
End With
End Sub
Any help is appreciated!