I have an excel spreadsheet of a BOM that I'm trying to conditionally format. The data is laid out such that column A is the item number. Since the BOM has alternates, there are repeated numbers. I want to go through the spreadsheet and for each item number, find the item with "Active" in column F and highlight them green and hide the alternates on the other rows. If there is no "active" item, I want to highlight the items as yellow and keep them displayed. I have the current vba script which does the highlighting. If you look at the example data I basically want a single line for each item number which shows the active part, but if there is no active part, to show the historical or discontinued parts in yellow
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim icolor As Integer
Dim lastrow As Long
Dim i As Integer
Dim cell As Range
Dim sheetname As String
sheetname = Application.ActiveSheet.Name
With Worksheets(sheetname)
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
Application.ScreenUpdating = False
For Each cell In Range("F1:F" & lastrow)
Select Case cell.Value
Case Is = "Active"
cell.EntireRow.Interior.ColorIndex = 10
Case Is = "Status"
cell.EntireRow.Interior.ColorIndex = 15
Case Is = ""
cell.EntireRow.Interior.ColorIndex = 2
cell.EntireRow.Hidden = True
Case Else
cell.EntireRow.Interior.ColorIndex = 6
End Select
Next cell
Application.ScreenUpdating = True
End Sub

Worksheet_Change? Since the cells in col F doesn't change automatically.