Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 24
Default More than 3 Conditional Formats

Hi
Hope someone can help, as I seem to have got myself stuck.

I am currently trying to Conditionally Format a cell based on 4 conditions.
From code I have found on other posts, I have got most of it working.
However, the bit that doesnt work is the most important bit - Applying the
Format !!

Code is posted below.
As you can see the code is triggered by a change in value on the worksheet.
However, the cell I want formated is relative to the changed cell, and is the
main way in which it has been modified from the other helpful posts. But I
cannot see why this would prevent it working.

Could someone please let me know how to fix it? - I would like to avoid
loading in add-ins etc, as the finished spreadsheet will be used by many
people.
And, if possible, explain why the error is occurring so I can try and avoid
doing it again for a.n.other problem I have to solve/automate.

Thanks very much for any help you can give

Kris

================================================== =
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Num As Long
Dim rng As Range
Dim ProbImpact_rng As Range
Dim ScoreOffset As Integer
Dim vRngInput As Variant

On Error GoTo endit
Select Case Target.Column
Case Is = Range("tbl_Orig_CostProb_Hdr").Column
Set ProbImpact_rng = Range("tbl_Orig_CostProb")
ScoreOffset = 2
Case Is = Range("tbl_Orig_CostImpact_Hdr").Column
Set ProbImpact_rng = Range("tbl_Orig_CostImpact")
ScoreOffset = 1
Case Is = Range("tbl_Orig_ProgProb_Hdr").Column
Set ProbImpact_rng = Range("tbl_Orig_ProgProb")
ScoreOffset = 2
Case Is = Range("tbl_Orig_ProgImpact_Hdr").Column
Set ProbImpact_rng = Range("tbl_Orig_ProgImpact")
ScoreOffset = 1
Case Is = Range("tbl_Resid_CostProb_Hdr").Column
Set ProbImpact_rng = Range("tbl_Resid_CostProb")
ScoreOffset = 2
Case Is = Range("tbl_Resid_CostImpact_Hdr").Column
Set ProbImpact_rng = Range("tbl_Resid_CostImpact")
ScoreOffset = 1
Case Is = Range("tbl_Resid_ProgProb_Hdr").Column
Set ProbImpact_rng = Range("tbl_Resid_ProgProb")
ScoreOffset = 2
Case Is = Range("tbl_Resid_ProgImpact_Hdr").Column
Set ProbImpact_rng = Range("tbl_Resid_ProgImpact")
ScoreOffset = 1
End Select

'Check Target Cell is in a Defined Range _
and not just the same column
Set vRngInput = Intersect(Target, ProbImpact_rng)
If vRngInput Is Nothing Then Exit Sub

Application.EnableEvents = False
'Determine the color
Select Case Target.Offset(0, ScoreOffset).Value
Case Is 39
Num = 16 'black
Case Is 20
Num = 3 'red
Case Is 9
Num = 36 'yellow
Case Is 0
Num = 34 'green
End Select
'Apply the color
Target.Offset(0, ScoreOffset).Interior.ColorIndex = Num
endit:
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
More than 3 conditional formats Ninjapowa Excel Discussion (Misc queries) 3 September 21st 06 03:52 PM
More than three conditional formats? bludovico Excel Discussion (Misc queries) 1 August 3rd 05 08:36 PM
How do I add more Conditional Formats? Saint Excel Discussion (Misc queries) 2 April 26th 05 08:30 PM
Using Conditional Formats Scott Excel Discussion (Misc queries) 2 March 10th 05 08:08 PM
Any way to have more than three conditional formats? Bill Brehm Excel Worksheet Functions 1 December 7th 04 10:37 AM


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