![]() |
Greater than 3 condtional formating rules in Excel
As the conditional formating command allows only 3 formats, is it possible to
have more than 3 conditional formats using cod? e.g. cell a1 would display red background if cell a2 = a cell a1 would display underlined text if cell a3 = b cell a1 would display bold text if cell a4 = c cell a1 would display bold italic text if cell a5 = d etc. Thanks in advance of any help John |
Greater than 3 condtional formating rules in Excel
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A2:A5" '<== change to suit On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target Select Case .Address(False, False) Case "A2": If .Value = "a" Then Me.Range("A1").Interior.ColorIndex = 3 'red Else Me.Range("A1").Interior.ColorIndex = xlColorIndexNone End If Case "A3": Me.Range("A1").Font.Underline = .Value = "b" Case "A4": Me.Range("A1").Font.Bold = .Value = "c" Case "A5": Me.Range("A1").Font.Bold = .Value = "d" Me.Range("A1").Font.Italic = .Value = "d" End Select End With End If ws_exit: Application.EnableEvents = True End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- HTH Bob Phillips (replace xxxx in the email address with gmail if mailing direct) "John Davies" wrote in message ... As the conditional formating command allows only 3 formats, is it possible to have more than 3 conditional formats using cod? e.g. cell a1 would display red background if cell a2 = a cell a1 would display underlined text if cell a3 = b cell a1 would display bold text if cell a4 = c cell a1 would display bold italic text if cell a5 = d etc. Thanks in advance of any help John |
All times are GMT +1. The time now is 06:52 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com