Ok need some help because the error isn't making sense to me. I have 4 dates in column A with around 12 copies of each(12-Jan-24, 19-Jan-24, 26-Jan-24, 02-Feb-24). I want to select a cell in column A and run a macro that will select all rows that have a match. The code I have is working for the dates 12-Jan-24 and 19-Jan-24, but gives an error (see pic) when running the macro when I have either date 26-Jan-24 and 02-Feb-24 active. I plan to cut and paste selected rows as to another sheet within the workbook, eventually after figuring out this issue. Any help would be appreciated.
VBA Code:
Option Explicit
Sub Date_Match_Rows_Select()
Dim tableR As Range, cell As Range, d As Range
Dim s As String
Set tableR = Range("A:A")
Set d = Selection
For Each cell In tableR
If cell = d Then
s = s & cell.Row & ":" & cell.Row & ", "
End If
Next cell
s = Left(s, Len(s) - 2)
Range(s).Select
End Sub