Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default How do I change the color of cells with a macro

I was using conditional formatting, but this only gives three options, I need 5
I am looking for a simple piece of code which says

If cell A1 is not zero color the row green, for example.

I have tried With range, If Else and Case

I get the first color, then it will not change
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,522
Default How do I change the color of cells with a macro


You don't give us much

select case range("a1").value
case<0:mc=6
case2:mc=3
case else
end select
rows(1).interior.colorindex=mc


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Mike DFR" wrote in message
...
I was using conditional formatting, but this only gives three options, I
need 5
I am looking for a simple piece of code which says

If cell A1 is not zero color the row green, for example.

I have tried With range, If Else and Case

I get the first color, then it will not change


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 41
Default How do I change the color of cells with a macro

Hi Mike, you could try something like:

cv = Range("a1").Value
IC = Switch(cv 10, vbRed, cv 8, vbBlue, cv 6, vbYellow, cv 0, vbGreen)
Rows(1).Interior.Color = IC


Hth
Stu

"Mike DFR" wrote:

I was using conditional formatting, but this only gives three options, I need 5
I am looking for a simple piece of code which says

If cell A1 is not zero color the row green, for example.

I have tried With range, If Else and Case

I get the first color, then it will not change

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 41
Default How do I change the color of cells with a macro

Oops forgot to change the values to reflect your example - I am sure you will
get the idea though.

"stumac" wrote:

Hi Mike, you could try something like:

cv = Range("a1").Value
IC = Switch(cv 10, vbRed, cv 8, vbBlue, cv 6, vbYellow, cv 0, vbGreen)
Rows(1).Interior.Color = IC


Hth
Stu

"Mike DFR" wrote:

I was using conditional formatting, but this only gives three options, I need 5
I am looking for a simple piece of code which says

If cell A1 is not zero color the row green, for example.

I have tried With range, If Else and Case

I get the first color, then it will not change

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
Macro change sheet tab color and name Gene Augustin Excel Discussion (Misc queries) 7 March 8th 09 09:03 PM
Change the Color of a Cell through a Macro JakeShipley2008 Excel Discussion (Misc queries) 4 June 9th 08 05:57 PM
Macro to change cell color Patti F Excel Discussion (Misc queries) 2 April 28th 06 07:13 PM
Macro To Change Cell Color When Value Changes carl Excel Worksheet Functions 4 March 14th 06 08:24 PM
macro color change Dan Excel Worksheet Functions 0 February 15th 05 09:35 PM


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