Home |
Search |
Today's Posts |
#1
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Automatically change cell colors based on date in cell | Excel Discussion (Misc queries) | |||
How to have row color change based on one cell to 4 colors | Excel Discussion (Misc queries) | |||
Can an excel cell automatically change fill colors based on values | Excel Discussion (Misc queries) | |||
Is it possible to change colors of cells based on value in cell (. | Excel Worksheet Functions | |||
How to change cell colors based on an IF statement formula? | Excel Programming |