PC Review


Reply
Thread Tools Rate Thread

Changing cell color based on a value in another cell

 
 
ordnance1
Guest
Posts: n/a
 
      23rd Jan 2008
I need a macro which will look at each row and if the cell in column Z =2
then the cell in column C should be formatted Yellow, if it = 3 the cell will
be formatted Red and if it is greater than 3 the cell will be formatted
Grey. There are 941 rows startimng at row 7. I know this can be done as a
conditional format, but this is for use with Office 2003 and because of other
conditional formats I am using I have exceeded the three allowed conditional
formats
 
Reply With Quote
 
 
 
 
ryguy7272
Guest
Posts: n/a
 
      23rd Jan 2008
This should do what you want:

Sub ColorCells()
Dim rCell As Range
Dim nCount As Long
With Range("Z7:Z100")
..Interior.ColorIndex = xlColorIndexNone
For Each rCell In .Cells
If rCell = "2" Then
rCell.Offset(0, -23).Interior.ColorIndex = 6
End If
If rCell = "3" Then
rCell.Offset(0, -23).Interior.ColorIndex = 3
End If
If rCell > "3" Then
rCell.Offset(0, -23).Interior.ColorIndex = 15
End If

Next rCell
End With
End Sub


Regards,
Ryan--

--
RyGuy


"ordnance1" wrote:

> I need a macro which will look at each row and if the cell in column Z =2
> then the cell in column C should be formatted Yellow, if it = 3 the cell will
> be formatted Red and if it is greater than 3 the cell will be formatted
> Grey. There are 941 rows startimng at row 7. I know this can be done as a
> conditional format, but this is for use with Office 2003 and because of other
> conditional formats I am using I have exceeded the three allowed conditional
> formats

 
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
Changing Cell Background Color based on data from another cell Speedy Microsoft Excel Misc 2 16th Mar 2009 04:10 PM
Changing a color in a cell based on the text in another cell Ryan Microsoft Excel Misc 3 13th Nov 2008 10:17 PM
Re: Changing cell text color based on cell number W. Wheeler Microsoft Excel Programming 1 23rd Apr 2007 07:24 AM
Re: Changing cell text color based on cell number W. Wheeler Microsoft Excel Programming 0 22nd Apr 2007 11:56 PM
Changing cell text color based on cell number =?Utf-8?B?c2NvdHR5?= Microsoft Excel Programming 9 14th Apr 2007 06:34 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:12 PM.