Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 2
Default Change row colors based on a cell value

Trying to change a row color based on the subtraction of 2 cells

Have the following code as a macro on an update button:

Sub Update_Row_Colors()

Dim LRow As Integer
Dim LCell As String
Dim LColorCells As String
'Start at row 2
LRow = 2
SCell = 1

'Update row colors for the first 2000 rows
While LRow < 2000
LCell = "H" & LRow
'Color will changed in columns A to G
LColorCells = "A" & LRow & ":" & "G" & LRow
'Color set to Red or Green
If Left(Range(LCell).Value, 6) = 0 Then
Range(LColorCells).Interior.ColorIndex = 4
Range(LColorCells).Interior.Pattern = xlSolid
Else
Range(LColorCells).Interior.ColorIndex = 3
End If

If Left(Range(LCell).Value, 6) = "" Then
Rows(LRow & ":" & LRow).Select
Range(LColorCells).Interior.ColorIndex = xlNone
End If

LRow = LRow + 1
Wend

Range("A1").Select

End Sub

The sheet I am working with has column H as the sum(d3-e3) through sum(d100-e100. The problem is when the H column value is #value! is stops with a runtime error '13' type mismatch. How do I fix that?
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
Automatically change cell colors based on date in cell Greg Excel Discussion (Misc queries) 2 January 27th 09 05:55 PM
How to have row color change based on one cell to 4 colors Mel Excel Discussion (Misc queries) 1 September 20th 06 10:47 PM
Can an excel cell automatically change fill colors based on values John Clark Excel Discussion (Misc queries) 1 February 5th 05 05:21 PM
Is it possible to change colors of cells based on value in cell (. LC Excel Worksheet Functions 3 January 14th 05 05:27 AM
How to change cell colors based on an IF statement formula? Tom Woolman Excel Programming 3 November 21st 03 07:35 PM


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