Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 231
Default Override conditional formatting with code

Does anyone know how to override conditional formatiing with code?

Thanks,

Sarah
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,339
Default Override conditional formatting with code

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 231
Default Override conditional formatting with code

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,718
Default Override conditional formatting with code

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 231
Default Override conditional formatting with code

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
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
Override a Formula John K. Excel Discussion (Misc queries) 4 February 12th 07 07:47 PM
Macro code to delete conditional formatting Bovine Jones Excel Discussion (Misc queries) 5 October 19th 06 08:39 AM
Zip Code Formatting JWCrosby New Users to Excel 8 July 1st 06 11:17 AM
zip code formatting MLD Excel Discussion (Misc queries) 1 August 19th 05 04:00 PM
Cell Value Override saschamps9903 Excel Discussion (Misc queries) 0 January 21st 05 09:53 PM


All times are GMT +1. The time now is 02:20 PM.

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"