How to select adjacent cells in the column that have the same valuesas the active cell?

  • Thread starter Thread starter jvdx
  • Start date Start date
J

jvdx

For example A1:A5 have the same content "cand38781." How can I select all of them with a macro code?

Thanks in advance.
 
For example A1:A5 have the same content "cand38781." How can I select all of them with a macro code?



Thanks in advance.

I don't think I have a full grasp of what you want but this may get you started.

Option Explicit
Sub PickEm()
Dim c As Range
Dim Data As Range
Dim i As String
Dim ans As String
i = Range("G1").Value

For Each c In Range("Data")
If c.Value = i Then c.Interior.ColorIndex = 24 ' 3, 20, 24
Next

ans = MsgBox("Clear color selection?", vbYesNo, "Yellar")
Select Case ans
Case vbYes
Range("Data").Interior.ColorIndex = xlNone
Case vbNo
Exit Sub
End Select

End Sub

HTH
Regards,
Howard
 
Back
Top