Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Amy
 
Posts: n/a
Default Need more than 2 conditions in Conditional Formatting

Is there a way to have more than just the 3 conditions in formatting or to
work around it?

I have a range of b4:b35 and I need to highlight cell different colors
depending on cell value..
If cell =0 then fill with red
if cell =1 then fill with yellow
if cell = 2 then fill with green
if cell = 3 then fill with blue
if cell =off then fill with grey

so as of right now I need 5 conditions unless oen of you wonderful experts
out there have an alternative solution for me....

thank you in advance
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips
 
Posts: n/a
Default Need more than 2 conditions in Conditional Formatting

An example


'-----------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
'-----------------------------------------------------------------
Const WS_RANGE As String = "B4:B35"

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
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

(remove nothere from email address if mailing direct)

"Amy" wrote in message
...
Is there a way to have more than just the 3 conditions in formatting or to
work around it?

I have a range of b4:b35 and I need to highlight cell different colors
depending on cell value..
If cell =0 then fill with red
if cell =1 then fill with yellow
if cell = 2 then fill with green
if cell = 3 then fill with blue
if cell =off then fill with grey

so as of right now I need 5 conditions unless oen of you wonderful experts
out there have an alternative solution for me....

thank you in advance



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Amy
 
Posts: n/a
Default Need more than 2 conditions in Conditional Formatting

Thanks for trying to help Bob but apparently I am doing something incorrect.
I went into the view code option of the sheet, pasted your code into it and
edited it to fit my values amd added 2 additonal and nothing happens. I no
nothing about writing code unfortunately and am at a loss. Any other thoughts?

"Bob Phillips" wrote:

An example


'-----------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
'-----------------------------------------------------------------
Const WS_RANGE As String = "B4:B35"

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
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

(remove nothere from email address if mailing direct)

"Amy" wrote in message
...
Is there a way to have more than just the 3 conditions in formatting or to
work around it?

I have a range of b4:b35 and I need to highlight cell different colors
depending on cell value..
If cell =0 then fill with red
if cell =1 then fill with yellow
if cell = 2 then fill with green
if cell = 3 then fill with blue
if cell =off then fill with grey

so as of right now I need 5 conditions unless oen of you wonderful experts
out there have an alternative solution for me....

thank you in advance




  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips
 
Posts: n/a
Default Need more than 2 conditions in Conditional Formatting

Amy,

can you show the code you entered?

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Amy" wrote in message
...
Thanks for trying to help Bob but apparently I am doing something

incorrect.
I went into the view code option of the sheet, pasted your code into it

and
edited it to fit my values amd added 2 additonal and nothing happens. I no
nothing about writing code unfortunately and am at a loss. Any other

thoughts?

"Bob Phillips" wrote:

An example


'-----------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
'-----------------------------------------------------------------
Const WS_RANGE As String = "B4:B35"

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
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

(remove nothere from email address if mailing direct)

"Amy" wrote in message
...
Is there a way to have more than just the 3 conditions in formatting

or to
work around it?

I have a range of b4:b35 and I need to highlight cell different colors
depending on cell value..
If cell =0 then fill with red
if cell =1 then fill with yellow
if cell = 2 then fill with green
if cell = 3 then fill with blue
if cell =off then fill with grey

so as of right now I need 5 conditions unless oen of you wonderful

experts
out there have an alternative solution for me....

thank you in advance






  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
David McRitchie
 
Posts: n/a
Default Need more than 2 conditions in Conditional Formatting

Hi Amy,
I think you installed the code as you would an event macro, but it is not an event macro.
Though you could install an event macro that applies to only one sheet, and
would be automatically invoked, example in
http://www.mvps.org/dmcritchie/excel/event.htm#case

The code you got from Bob must go into a module and you might invoke
it from Alt+F8 once installed.
http://www.mvps.org/dmcritchie/excel....htm#havemacro

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Amy" wrote in message ...
Thanks for trying to help Bob but apparently I am doing something incorrect.
I went into the view code option of the sheet, pasted your code into it and
edited it to fit my values amd added 2 additonal and nothing happens. I no
nothing about writing code unfortunately and am at a loss. Any other thoughts?

"Bob Phillips" wrote:

An example


'-----------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
'-----------------------------------------------------------------
Const WS_RANGE As String = "B4:B35"

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
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

(remove nothere from email address if mailing direct)

"Amy" wrote in message
...
Is there a way to have more than just the 3 conditions in formatting or to
work around it?

I have a range of b4:b35 and I need to highlight cell different colors
depending on cell value..
If cell =0 then fill with red
if cell =1 then fill with yellow
if cell = 2 then fill with green
if cell = 3 then fill with blue
if cell =off then fill with grey

so as of right now I need 5 conditions unless oen of you wonderful experts
out there have an alternative solution for me....

thank you in advance








  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
amy
 
Posts: n/a
Default Need more than 2 conditions in Conditional Formatting

Thank you both. Now that I "invoked" the code Bob gave me (with my data) it
works. Thank you both for your help and follow through.

"Bob Phillips" wrote:

Amy,

can you show the code you entered?

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Amy" wrote in message
...
Thanks for trying to help Bob but apparently I am doing something

incorrect.
I went into the view code option of the sheet, pasted your code into it

and
edited it to fit my values amd added 2 additonal and nothing happens. I no
nothing about writing code unfortunately and am at a loss. Any other

thoughts?

"Bob Phillips" wrote:

An example


'-----------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
'-----------------------------------------------------------------
Const WS_RANGE As String = "B4:B35"

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
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

(remove nothere from email address if mailing direct)

"Amy" wrote in message
...
Is there a way to have more than just the 3 conditions in formatting

or to
work around it?

I have a range of b4:b35 and I need to highlight cell different colors
depending on cell value..
If cell =0 then fill with red
if cell =1 then fill with yellow
if cell = 2 then fill with green
if cell = 3 then fill with blue
if cell =off then fill with grey

so as of right now I need 5 conditions unless oen of you wonderful

experts
out there have an alternative solution for me....

thank you in advance






  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips
 
Posts: n/a
Default Need more than 2 conditions in Conditional Formatting

Well that's odd, because it was event code, and it should have worked as you
entered the data. If the data already existed, you would have needed to edit
it, even without actually changing it, to force the change event.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"amy" wrote in message
...
Thank you both. Now that I "invoked" the code Bob gave me (with my data)

it
works. Thank you both for your help and follow through.

"Bob Phillips" wrote:

Amy,

can you show the code you entered?

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Amy" wrote in message
...
Thanks for trying to help Bob but apparently I am doing something

incorrect.
I went into the view code option of the sheet, pasted your code into

it
and
edited it to fit my values amd added 2 additonal and nothing happens.

I no
nothing about writing code unfortunately and am at a loss. Any other

thoughts?

"Bob Phillips" wrote:

An example


'-----------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
'-----------------------------------------------------------------
Const WS_RANGE As String = "B4:B35"

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
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

(remove nothere from email address if mailing direct)

"Amy" wrote in message
...
Is there a way to have more than just the 3 conditions in

formatting
or to
work around it?

I have a range of b4:b35 and I need to highlight cell different

colors
depending on cell value..
If cell =0 then fill with red
if cell =1 then fill with yellow
if cell = 2 then fill with green
if cell = 3 then fill with blue
if cell =off then fill with grey

so as of right now I need 5 conditions unless oen of you wonderful

experts
out there have an alternative solution for me....

thank you in advance








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
I have more than 6 conditions when using conditional formatting? Magda Excel Worksheet Functions 3 March 1st 06 09:15 AM
More than 3 Conditional Formatting Conditions Beth H Excel Worksheet Functions 12 January 6th 06 07:35 PM
Conditional formatting capability for 20+ conditions not just 3. Charles Smittenaar Excel Discussion (Misc queries) 2 October 28th 05 11:30 PM
Conditional formatting: I have five conditions, how to do this? Danzguy Excel Discussion (Misc queries) 2 May 11th 05 08:21 AM
Adding more than three Conditions to 'Conditional Formatting' David McRitchie Excel Discussion (Misc queries) 1 November 27th 04 06:03 PM


All times are GMT +1. The time now is 04:30 PM.

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

About Us

"It's about Microsoft Excel"