Hey there,
What I wish to acheive by this macro is that all rows with value in column B being the same as the chosen value from a dropdown list (in d2) are highlightet, when the macro is run. Also, when d2 is empty and the macro is run, I want the (by the macro) previously highlightet rows to go back to normal (not highlightet). Hope that makes sense
The code below (not working) shows what I got at this point.
I also considered making it a Worksheet_Change event instead, but i guessed this would make it more demanding than a sub to run by click on a commandbutton. Is that right?
Thanks a lot in advance for your help.
Sub Highlight()
Dim lngRow As Long
Application.ScreenUpdating = False
lngRow = Range("B4").End(xlDown).Row
Do While lngRow > 0
If Range("d2").Value = "" Then
Rows(lngRow).Interior.Pattern = xlNone
Else if Cells(lngRow, 2).Value = Range("d2").Value Then
Rows(lngRow).Interior.ColorIndex = 3
End If
lngRow = lngRow - 1
Loop
Application.ScreenUpdating = True
End Sub
Bookmarks