Hi all,
I've decided to forgo the 'Remove highlights button' . However, for the benefit of those who are trying to find the macro that will find the unique string and higlight the cell, here it is:
Sub FindAndHighlight(SearchData As Variant, SearchRange As Range, HighlightColor As Long)
Dim FirstAddress As String
Dim SearchCell As Range
Dim SrcWks As Worksheet
Set SrcWks = Worksheets(SearchRange.Parent.Name)
Set SearchCell = SearchRange.Find(What:=SearchData, After:=SearchRange.Cells(1, 1), _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, MatchCase:=False)
If Not SearchCell Is Nothing Then
FirstAddress = SearchCell.Address
Do
SearchCell.Cells.Interior.ColorIndex = HighlightColor
Set SearchCell = SearchRange.FindNext(SearchCell)
Loop While Not SearchCell Is Nothing And SearchCell.Address <> FirstAddress
End If
End Sub
Sub HighlightRisk()
Dim LastRow As Long
Dim RiskCol As Variant
Dim RiskRange As Range
Dim StartRow As Long
RiskCol = "B"
StartRow = 1
With Worksheets("My Requirement")
LastRow = .Cells(.Rows.Count, RiskCol).End(xlUp).Row
LastRow = IIf(LastRow < StartRow, StartRow, LastRow)
Set RiskRange = .Range(.Cells(StartRow, RiskCol), .Cells(LastRow, RiskCol))
End With
FindAndHighlight "Unknown", RiskRange, 6 'Yellow'
FindAndHighlight "ERROR", RiskRange, 3 'Red'
End Sub
Hope it helps! Happy coding! =)
Bookmarks