Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 343
Default Changing cell color based on value in another cell

I have a worksheet with 941 rows. I need a macro that will look at each row
and if the value in of the cell in column Z of that row = 2 it should format
the cell in column C Yellow, if the cell in column Z of that row = 3 it
should format the cell to Red, and if the cell in column Z of that row is
grater than 3 it should format the cell to Grey with white text. If the Cell
in column Z is equal to 1 or less the cell in column C should be the normal
format which has been set for it.

I know this can be done easily with conditional formatting in Office 2007,
but I am doing this to be used with Office 2003 and with the other
conditional formats I have in place, I have exceeded the 3 conditional
format limit.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Changing cell color based on value in another cell

On Mon, 21 Jan 2008 14:49:01 -0800, "Patrick C. Simonds"
wrote:

In the worksheet properties:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim X As Long
For X = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row To 1 Step
-1
If ActiveSheet.Cells(X, "Z").Value = 2 Then
With ActiveSheet.Cells(X, "C").Interior
.ColorIndex = 6
End With

ElseIf ActiveSheet.Cells(X, "Z").Value = 3 Then
With ActiveSheet.Cells(X, "C").Interior
.ColorIndex = 3
End With

ElseIf ActiveSheet.Cells(X, "Z").Value 3 Then
With ActiveSheet.Cells(X, "C").Font
.ColorIndex = 2
End With
With ActiveSheet.Cells(X, "C").Interior
.ColorIndex = 16
End With
End If
Next
End Sub


I have a worksheet with 941 rows. I need a macro that will look at each row
and if the value in of the cell in column Z of that row = 2 it should format
the cell in column C Yellow, if the cell in column Z of that row = 3 it
should format the cell to Red, and if the cell in column Z of that row is
grater than 3 it should format the cell to Grey with white text. If the Cell
in column Z is equal to 1 or less the cell in column C should be the normal
format which has been set for it.

I know this can be done easily with conditional formatting in Office 2007,
but I am doing this to be used with Office 2003 and with the other
conditional formats I have in place, I have exceeded the 3 conditional
format limit.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Changing cell color based on value in another cell

On Mon, 21 Jan 2008 14:49:01 -0800, "Patrick C. Simonds"
wrote:

Correction

In the worksheet properties:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim X As Long
For X = ActiveSheet.Cells(Rows.Count, "Z").End(xlUp).Row To 1 Step
-1
If ActiveSheet.Cells(X, "Z").Value = 2 Then
With ActiveSheet.Cells(X, "C").Interior
.ColorIndex = 6
End With

ElseIf ActiveSheet.Cells(X, "Z").Value = 3 Then
With ActiveSheet.Cells(X, "C").Interior
.ColorIndex = 3
End With

ElseIf ActiveSheet.Cells(X, "Z").Value 3 Then
With ActiveSheet.Cells(X, "C").Font
.ColorIndex = 2
End With
With ActiveSheet.Cells(X, "C").Interior
.ColorIndex = 16
End With
End If
Next
End Sub

Sorry. I used "D" for testing as "Z" was off my screen.


I have a worksheet with 941 rows. I need a macro that will look at each row
and if the value in of the cell in column Z of that row = 2 it should format
the cell in column C Yellow, if the cell in column Z of that row = 3 it
should format the cell to Red, and if the cell in column Z of that row is
grater than 3 it should format the cell to Grey with white text. If the Cell
in column Z is equal to 1 or less the cell in column C should be the normal
format which has been set for it.

I know this can be done easily with conditional formatting in Office 2007,
but I am doing this to be used with Office 2003 and with the other
conditional formats I have in place, I have exceeded the 3 conditional
format limit.

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
Changing Cell Background Color based on data from another cell Speedy Excel Discussion (Misc queries) 2 March 16th 09 04:10 PM
Changing a color in a cell based on the text in another cell Ryan Excel Discussion (Misc queries) 3 November 13th 08 10:17 PM
Changing cell text color based on cell number W. Wheeler Excel Programming 1 April 23rd 07 07:24 AM
Changing cell text color based on cell number W. Wheeler Excel Programming 0 April 22nd 07 11:56 PM
Changing cell text color based on cell number scotty Excel Programming 9 April 14th 07 06:34 AM


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

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

About Us

"It's about Microsoft Excel"