PDA

View Full Version : Find Multiple Cell Values



Cue313
10-13-2008, 08:26 AM
Hello!For the following line:

whatwant = Sheets("300-+").Range("$A$65000").Value

It will only search for that cell value that is from sheet "300-+" and color that value on sheet "MultAdjDaily". But instead of one value, I would like it to search for multiple cells with values and color them on "MultAdjDaily". I tried the following but it did not work:

whatwant = Sheets("300-+").Range("$A$65000:$A$65125").Value

I want the code to take the multiple cells with values that are on sheet "300-+" and find them and color them on sheet "MultAdjDaily".Can anyone show me what to change in order for that to work? Here is my code:

Sub find_and_color()
Dim rCell As Range
Dim whatwant As String
whatwant = Sheets("300-+").Range("$A$65000").Value
Range("A1").Select
For Each rCell In Sheets("MultAdjDaily").Range("$C$6:$C$3001")
If rCell.Value Like whatwant Then
rCell.EntireRow.Resize(1, 14).Interior.ColorIndex = 33
End If
Next rCell
End Sub

Thanks for your help.
Cue313

GTO
10-13-2008, 12:22 PM
Greetings Cue,

Presuming I understood what you are trying to do, this may help.

Mark

Sub find_and_color()
Dim rCell_OuterLoop As Range
Dim rCell_InnerLoop As Range
For Each rCell_OuterLoop In Worksheets("300-+").Range("A65000:A65125")

If Not rCell_OuterLoop.Value = Empty Then
For Each rCell_InnerLoop In Worksheets("MultAdjDaily").Range("C6:C3001")
If rCell_InnerLoop.Value = rCell_OuterLoop.Value Then
rCell_InnerLoop.Interior.ColorIndex = 33
End If
Next rCell_InnerLoop
End If

Next rCell_OuterLoop
End Sub