Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
color fill button is not adding color to my spread sheet | Excel Worksheet Functions | |||
change fill color of a range of cells based on color of a cell? | Excel Programming | |||
My fill color and font color do not work in Excel Std Edition 2003 | Excel Discussion (Misc queries) | |||
Excel 2003 will not display color fonts or color fill cells | Excel Worksheet Functions | |||
My excel 2003 wont let me fill cells with color or color the tabs. | New Users to Excel |