I have a list of ids in one column on Sheet "A". On sheet "B" i have these ids spread out in a table (a range). How do i search through the range to see if each value listed on sheet A exists on Sheet B? I'm wanting to make sure that all values in the one column on Sheet A exist on Sheet B. This macro is supposed to check and Highlight the values that do exist. Thus, any values that dont exist will not be highlighted and i can easily address. Currently we are manually updating but i need it to be dynamic with as many changes as we are making.
Below is what i have tried so far but am getting a "Next without For" error. i've coded in vba but its been a LONG time. Any help is appreciated. Btw, i didnt really care about the color until i get it working so i just picked a number.
Sub CaseIdCheck()
Dim i, j, x As Integer
Dim intValueToFind, testCaseId, tciPass1, tciPass2 As String
Dim range1, range2 As Range
range1 = Application.GotoActiveWorkbook.Sheets("B").Range("C4:U50")
range2 = Application.GotoActiveWorkbook.Sheets("A").Range("i3:i145")
For x = 1 To ActiveWorkbook.Sheets("A").CountA(Columns(9))
If Cells(x, 9).Value <> Null Then
testCaseId = Sheets("A").Cells(x, 9).Value
For i = 1 To 100
For j = 1 To 100
If Sheets("B").Cells(i, j).Value = testCaseId Then
Sheets("A").Cells(x, 9).Interior.ColorIndex = 36
Else
Next j
Next i
End If
Next x
Else
MsgBox ("end")
End Sub
Does this need to be VBA? You can do this with a named range and conditional highlighting.
Create a new named range (we'll call it rngCheck
) that is defined with this named range formula:
=B!$1:$1048576
Then apply this conditional format to sheet "A" column I:
=COUNTIF(rngCheck,I1)>0
And select the desired color (the RGB of ColorIndex 36 is R 255, G 255, B153)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.