View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Allllen Allllen is offline
external usenet poster
 
Posts: 341
Default Add Fill Color to Row

Dim lastRow As Long
Dim i As Integer

lastRow = Cells(Rows.Count, "G").End(xlUp).Row

For i = lastRow To 1 Step -1
If Cells(i, "G").Value < 0 And Cells(i, "G").Value -5 Then
Rows(i).Delete
ElseIf Cells(i, "G").Value < -5 Then
With Range(Cells(i, 1), Cells(i, 8))
.Interior.ColorIndex = 3
.Font.ColorIndex = 2
End With
End If
Next i
--
Allllen


"RSteph" wrote:

Here's how I'm cycling through:

Dim lastRow As Long 'Used to hold the value of last row on the sheet.
Dim i As Integer 'Used to incriment For Loop.

lastRow = Cells(Rows.Count, "G").End(xlUp).Row 'Get the last row on the page.

For i = lastRow To 1 Step -1 'Loop through to the end of the page, from
bottom up.
If Cells(i, "G").Value < 0 And Cell(i, "G").Value -5 Then
Rows(i).Delete 'Delete row.
ElseIf Cells(i, "G").Value < -5 Then
<Code Inserted Here
End If

Next i 'Increment counter and reloop


"Sandy" wrote:

I'm not sure how you are cycling through all the rows but insert this
into the code
Assume that mCell is the expression of the cell you are checking in the
row

If mCell -5 then
mCell.EntireRow.Interior.ColorIndex = 3
End If

If you are not sure about the "mCell" expression post your code that
cycles through the rows and I'll be able to put the code in better
context.

Sandy


RSteph wrote:
I've got a Macro that runs through all the rows on my page, and removes in
rows where the check value is between 0 and -5. Any row that has a check
value greater than -5 (technically less than) I want it to make the row from
column A to H Red in the background. So that the user will know to look at
that row when done.

How would I go about changing the fill color value for a row of cells?