Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2008

Tip: Looking for answers? Try searching our database.

Changing cell color based on a value in another cell

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ordnance1 - 23 Jan 2008 00:07 GMT
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
ryguy7272 - 23 Jan 2008 20:09 GMT
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--

Signature

RyGuy

> 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
[quoted text clipped - 3 lines]
> conditional formats I am using I have exceeded the three allowed conditional
> formats
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.