Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Drop Down lists and condtional formating grissom 345 Excel Worksheet Functions 2 June 27th 09 09:02 AM
conditional formating greater than fearthespear Excel Discussion (Misc queries) 1 November 5th 08 01:45 AM
Condtional Formating Is mise le meas, Excel Worksheet Functions 3 October 31st 08 02:41 PM
Conditional Formating if Greater Than or Less Than other column CClio333 Excel Worksheet Functions 2 February 26th 08 09:23 AM
Condtional formating -- any wildcard use? MatthewTap Excel Discussion (Misc queries) 5 September 30th 05 12:37 AM


All times are GMT +1. The time now is 07:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"