PC Review


Reply
Thread Tools Rate Thread

Change the color of a range of cells.

 
 
Srajes
Guest
Posts: n/a
 
      24th Jun 2009

Hi,

I need to change the color of a range of cells depending up on the value in
another cell.
Consider cells
1 2 3 4 5
, I need to change the color of all thse 5 cells depending up on the value
in cell 5.

Thanks in advance for your help.
SR
 
Reply With Quote
 
 
 
 
Srajes
Guest
Posts: n/a
 
      24th Jun 2009

Sure, I will take care in future.

"Don Guillett" wrote:

> Pls post in ONLY ONE GROUP
>
> --
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> (E-Mail Removed)
> "Srajes" <(E-Mail Removed)> wrote in message
> news0925857-68D0-4310-9D91-(E-Mail Removed)...
> > Hi,
> >
> > I need to change the color of a range of cells depending up on the value
> > in
> > another cell.
> > Consider cells
> > 1 2 3 4 5
> > , I need to change the color of all thse 5 cells depending up on the value
> > in cell 5.
> >
> > Thanks in advance for your help.
> > SR

>
>

 
Reply With Quote
 
Patrick Molloy
Guest
Posts: n/a
 
      24th Jun 2009

you can do this easily with Conditional Formatting

or in code, something akin to this:-
If Range("A5")=somevalue then range("A1:A5").Interior.Colorindex =
somecolorcode
where you put appropriate values in for somevalue and somecolorcode

"Srajes" <(E-Mail Removed)> wrote in message
news0925857-68D0-4310-9D91-(E-Mail Removed)...
> Hi,
>
> I need to change the color of a range of cells depending up on the value
> in
> another cell.
> Consider cells
> 1 2 3 4 5
> , I need to change the color of all thse 5 cells depending up on the value
> in cell 5.
>
> Thanks in advance for your help.
> SR


 
Reply With Quote
 
Srajes
Guest
Posts: n/a
 
      24th Jun 2009

Conditinal formatting allows me to check only 3 conditions. I have 7
conditions. I am using Excel 2003.

"Patrick Molloy" wrote:

> you can do this easily with Conditional Formatting
>
> or in code, something akin to this:-
> If Range("A5")=somevalue then range("A1:A5").Interior.Colorindex =
> somecolorcode
> where you put appropriate values in for somevalue and somecolorcode
>
> "Srajes" <(E-Mail Removed)> wrote in message
> news0925857-68D0-4310-9D91-(E-Mail Removed)...
> > Hi,
> >
> > I need to change the color of a range of cells depending up on the value
> > in
> > another cell.
> > Consider cells
> > 1 2 3 4 5
> > , I need to change the color of all thse 5 cells depending up on the value
> > in cell 5.
> >
> > Thanks in advance for your help.
> > SR

>
>

 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      24th Jun 2009

Modify to suit.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Num As Long
Dim rng As Range
Dim vRngInput As Range
Set vRngInput = Range("A11")
If Range("E1") = "" Then Exit Sub
'Determine the color
Select Case Range("E1").Value
Case Is = 1: Num = 6 'yellow
Case Is = 2: Num = 10 'green
Case Is = 3: Num = 5 'blue
Case Is = 4: Num = 3 'red
Case Is = 5: Num = 46 'orange
End Select
'Apply the color
For Each rng In vRngInput
rng.Interior.ColorIndex = Num
Next rng
End Sub


Gord Dibben MS Excel MVP

On Wed, 24 Jun 2009 11:46:01 -0700, Srajes
<(E-Mail Removed)> wrote:

>Conditinal formatting allows me to check only 3 conditions. I have 7
>conditions. I am using Excel 2003.
>
>"Patrick Molloy" wrote:
>
>> you can do this easily with Conditional Formatting
>>
>> or in code, something akin to this:-
>> If Range("A5")=somevalue then range("A1:A5").Interior.Colorindex =
>> somecolorcode
>> where you put appropriate values in for somevalue and somecolorcode
>>
>> "Srajes" <(E-Mail Removed)> wrote in message
>> news0925857-68D0-4310-9D91-(E-Mail Removed)...
>> > Hi,
>> >
>> > I need to change the color of a range of cells depending up on the value
>> > in
>> > another cell.
>> > Consider cells
>> > 1 2 3 4 5
>> > , I need to change the color of all thse 5 cells depending up on the value
>> > in cell 5.
>> >
>> > Thanks in advance for your help.
>> > SR

>>
>>


 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      25th Jun 2009

Gord. OP using a drop down so, in the OTHER post, I suggested this vlookup
instead.

I found your drop down list and named the range colorpicks. I also named the
validation range to colorpicksA so you may now move it as I did , even to
another sheet, and it will still work because it is assigned to the named
range. Goto the table and change the color numbers as desired. I have also
attached colorpalette so you can see the colors. You had validation assigned
to the whole column. Do NOT do that. Now when you click on col M (if
validation there) the color will change according to the vlookup table.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> Columns("m").Column Then Exit Sub
Cells(Target.Row, 1).Resize(, 13).Interior.ColorIndex = _
Application.VLookup(Target, Range("colorpicks"), 2, 0)
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Gord Dibben" <gorddibbATshawDOTca> wrote in message
news:(E-Mail Removed)...
> Modify to suit.
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> Dim Num As Long
> Dim rng As Range
> Dim vRngInput As Range
> Set vRngInput = Range("A11")
> If Range("E1") = "" Then Exit Sub
> 'Determine the color
> Select Case Range("E1").Value
> Case Is = 1: Num = 6 'yellow
> Case Is = 2: Num = 10 'green
> Case Is = 3: Num = 5 'blue
> Case Is = 4: Num = 3 'red
> Case Is = 5: Num = 46 'orange
> End Select
> 'Apply the color
> For Each rng In vRngInput
> rng.Interior.ColorIndex = Num
> Next rng
> End Sub
>
>
> Gord Dibben MS Excel MVP
>
> On Wed, 24 Jun 2009 11:46:01 -0700, Srajes
> <(E-Mail Removed)> wrote:
>
>>Conditinal formatting allows me to check only 3 conditions. I have 7
>>conditions. I am using Excel 2003.
>>
>>"Patrick Molloy" wrote:
>>
>>> you can do this easily with Conditional Formatting
>>>
>>> or in code, something akin to this:-
>>> If Range("A5")=somevalue then range("A1:A5").Interior.Colorindex =
>>> somecolorcode
>>> where you put appropriate values in for somevalue and somecolorcode
>>>
>>> "Srajes" <(E-Mail Removed)> wrote in message
>>> news0925857-68D0-4310-9D91-(E-Mail Removed)...
>>> > Hi,
>>> >
>>> > I need to change the color of a range of cells depending up on the
>>> > value
>>> > in
>>> > another cell.
>>> > Consider cells
>>> > 1 2 3 4 5
>>> > , I need to change the color of all thse 5 cells depending up on the
>>> > value
>>> > in cell 5.
>>> >
>>> > Thanks in advance for your help.
>>> > SR
>>>
>>>

>


 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      25th Jun 2009

Thanks Don

Missed OTHER post, I guess.


Gord

On Thu, 25 Jun 2009 07:13:18 -0500, "Don Guillett"
<(E-Mail Removed)> wrote:

>Gord. OP using a drop down so, in the OTHER post, I suggested this vlookup
>instead.
>
>I found your drop down list and named the range colorpicks. I also named the
>validation range to colorpicksA so you may now move it as I did , even to
>another sheet, and it will still work because it is assigned to the named
>range. Goto the table and change the color numbers as desired. I have also
>attached colorpalette so you can see the colors. You had validation assigned
>to the whole column. Do NOT do that. Now when you click on col M (if
>validation there) the color will change according to the vlookup table.
>
>Private Sub Worksheet_Change(ByVal Target As Range)
> If Target.Column <> Columns("m").Column Then Exit Sub
> Cells(Target.Row, 1).Resize(, 13).Interior.ColorIndex = _
> Application.VLookup(Target, Range("colorpicks"), 2, 0)
>End Sub


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Change the color of a range of cells Don Guillett Microsoft Excel New Users 5 24th Jun 2009 08:02 PM
RE: change the color of a range of cells Eduardo Microsoft Excel Misc 0 24th Jun 2009 03:47 PM
Re: Change the color of a range of cells. Don Guillett Microsoft Excel Programming 0 24th Jun 2009 03:45 PM
change the color of a range of cells Srajes Microsoft Excel Misc 0 24th Jun 2009 03:41 PM
change fill color of a range of cells based on color of a cell? =?Utf-8?B?RGFyTWVsTmVs?= Microsoft Excel Programming 0 2nd Mar 2006 06:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:41 PM.