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

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.
 
L

lhkittle

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top