ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Add Fill Color to Row (https://www.excelbanter.com/excel-programming/376366-add-fill-color-row.html)

RSteph

Add Fill Color to Row
 
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?

Sandy

Add Fill Color to Row
 
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?



bobbo

Add Fill Color to Row
 
Assuming that your code nemd the range you wanted to change as rg1.

rg1.interior.colorindex = 3

3 is red
6 is yellow

Those are the indexes I know off of the top of my head. You can use the
immediate window to discover others.

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?



Allllen

Add Fill Color to Row
 
let rownumber is the number of the row which you want to colour

with range(cells(rownumber,1),cells(rownumber,8)) '1 is col A, 8 is col H
.Interior.ColorIndex = 3
.Font.ColorIndex = 2 ' sets font to white (visibility)
end with

etc etc

or you can use rows(rownumber).interior.colorindex
--
Allllen


"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?


Sandy

Add Fill Color to Row
 
Made a mistake use "<" instead of ""

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?



RSteph

Add Fill Color to Row
 
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?




Allllen

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?




RSteph

Add Fill Color to Row
 
Thank you all for the suggestions on various methods of completing this task.
I got the method working perfectly for what I need.


"Sandy" wrote:

Made a mistake use "<" instead of ""

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?





All times are GMT +1. The time now is 11:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com