Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default VB Cond. Formatting of Formula Cell

I used the code below to extend conditional formatting to 4 cases. It works
great on the cells that I manually enter values in, but not for the cells in
row 15 that contain the formulas. The formula values do update, but the cell
colors don't change when I delete the values above and re-enter new ones. It
worked fine the very first time I entered values, but there must be
additional code I need to make the formula cells realize that they're
supposed to change color when their calculated value changes. What am I
missing?? Thanks!
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "b9:p15"
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 Is = 4: .Interior.ColorIndex = 5 'blue
Case Is = 3: .Interior.ColorIndex = 10 'green
Case Is = 2: .Interior.ColorIndex = 6 'yellow
Case Is = "": .Interior.ColorIndex = None
Case Is = 0: .Interior.ColorIndex = 3 'red
End Select
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 772
Default VB Cond. Formatting of Formula Cell

I never have done this before so i don't know how far down the rabbit hole it
will go as far as complexity of dependents, but it works on some simple one
dependent formulas. What i did was said that when a target changes, check the
dependents as well and update their colors. Let me know, interested to see
what you get.

Select Case .Dependents.Value
Case Is = 4: .Dependents.Interior.ColorIndex = 5 'blue
Case Is = 3: .Dependents.Interior.ColorIndex = 10 'green
Case Is = 2: .Dependents.Interior.ColorIndex = 6 'yellow
Case Is = "": .Dependents.Interior.ColorIndex = None
Case Is = 0: .Dependents.Interior.ColorIndex = 3 'red
End Select

--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Joanna" wrote:

I used the code below to extend conditional formatting to 4 cases. It works
great on the cells that I manually enter values in, but not for the cells in
row 15 that contain the formulas. The formula values do update, but the cell
colors don't change when I delete the values above and re-enter new ones. It
worked fine the very first time I entered values, but there must be
additional code I need to make the formula cells realize that they're
supposed to change color when their calculated value changes. What am I
missing?? Thanks!
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "b9:p15"
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 Is = 4: .Interior.ColorIndex = 5 'blue
Case Is = 3: .Interior.ColorIndex = 10 'green
Case Is = 2: .Interior.ColorIndex = 6 'yellow
Case Is = "": .Interior.ColorIndex = None
Case Is = 0: .Interior.ColorIndex = 3 'red
End Select
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub

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
Cond. Formatting, Mod(Row) and cell conditions wynand Excel Discussion (Misc queries) 2 May 28th 10 10:53 AM
Cond. formatting, based on other cell values? GD Excel Discussion (Misc queries) 3 February 7th 09 07:26 PM
Cond. Formatting; If Cell B6 or B7 is blank I want Cell D12 to be Dr. Darrell Excel Discussion (Misc queries) 5 December 28th 08 08:54 PM
Matching Cell Colors (Cond. Formatting) [email protected] Excel Programming 1 July 6th 06 10:12 PM
Can I apply Cond. Formatting to a Formula result? SCrowley Excel Worksheet Functions 2 October 31st 05 08:31 PM


All times are GMT +1. The time now is 01:46 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"