PDA

View Full Version : [SOLVED] Highlight two sets of cells based on selection.



paulked
03-19-2017, 11:45 AM
At the moment I am using the code below (called from a Worksheet_SelectionChange event) to highlight all cells with the same text in them:



Sub HighLightCells()
Application.ScreenUpdating = False
On Error Resume Next
Range("M1").Interior.ColorIndex = Range("L1").Value
Range("O1").Interior.ColorIndex = Range("N1").Value
ActiveSheet.UsedRange.Cells.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:=ActiveCell
ActiveSheet.UsedRange.Cells.FormatConditions(1).Interior.ColorIndex = Range("l1").Value
Application.ScreenUpdating = True
If Selection = 0 Then
ActiveSheet.UsedRange.Cells.FormatConditions.Delete
End If
End Sub


I would like to highlight a second set of cells in a different colour based on a second selection but am struggling with the code.

For example
In the attached workbook I would like to send the fixture list to the Star Inn with the Star A fixtures highlighted in one colour and the Star B fixtures highlighted in another colour.

Any help would be appreciated, thanks.

18688

mdmackillop
03-19-2017, 12:24 PM
This uses conditional formatting only. No macros.

paulked
03-19-2017, 02:48 PM
Many thanks for that :thumb