Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Does anyone know how to override conditional formatiing with code?
Thanks, Sarah |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
If you mean use code for CF then see example below:
----------------------------------------------------------------- Private Sub Worksheet_Change(ByVal Target As Range) '----------------------------------------------------------------- Const WS_RANGE As String = "H1:H10" On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target Select Case .Value Case 1: .Interior.ColorIndex = 3 'red Case 2: .Interior.ColorIndex = 6 'yellow Case 3: .Interior.ColorIndex = 5 'blue Case 4: .Interior.ColorIndex = 10 'green 'etc. 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. "Sarah" wrote: Does anyone know how to override conditional formatiing with code? Thanks, Sarah |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
That worked. Thanks.
"Toppers" wrote: If you mean use code for CF then see example below: ----------------------------------------------------------------- Private Sub Worksheet_Change(ByVal Target As Range) '----------------------------------------------------------------- Const WS_RANGE As String = "H1:H10" On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target Select Case .Value Case 1: .Interior.ColorIndex = 3 'red Case 2: .Interior.ColorIndex = 6 'yellow Case 3: .Interior.ColorIndex = 5 'blue Case 4: .Interior.ColorIndex = 10 'green 'etc. 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. "Sarah" wrote: Does anyone know how to override conditional formatiing with code? Thanks, Sarah |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Conditional formatting overrides regular formatting. So the only way to
change the formatting that conditional formatting creates is to change the conditional formating rules or the conditional formatting format. To get an idea of the code you'd use to do that record a macro as you change it manually. -- Jim "Sarah" wrote in message ... Does anyone know how to override conditional formatiing with code? Thanks, Sarah |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Thanks for the clarification. Now I understand how it works.
"Jim Rech" wrote: Conditional formatting overrides regular formatting. So the only way to change the formatting that conditional formatting creates is to change the conditional formating rules or the conditional formatting format. To get an idea of the code you'd use to do that record a macro as you change it manually. -- Jim "Sarah" wrote in message ... Does anyone know how to override conditional formatiing with code? Thanks, Sarah |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Override a Formula | Excel Discussion (Misc queries) | |||
Macro code to delete conditional formatting | Excel Discussion (Misc queries) | |||
Zip Code Formatting | New Users to Excel | |||
zip code formatting | Excel Discussion (Misc queries) | |||
Cell Value Override | Excel Discussion (Misc queries) |