PC Review


Reply
Thread Tools Rate Thread

Add Fill Color to Row

 
 
=?Utf-8?B?UlN0ZXBo?=
Guest
Posts: n/a
 
      31st Oct 2006
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 With Quote
 
 
 
 
Sandy
Guest
Posts: n/a
 
      31st Oct 2006
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?


 
Reply With Quote
 
bobbo
Guest
Posts: n/a
 
      31st Oct 2006
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?


 
Reply With Quote
 
=?Utf-8?B?QWxsbGxlbg==?=
Guest
Posts: n/a
 
      31st Oct 2006
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?

 
Reply With Quote
 
Sandy
Guest
Posts: n/a
 
      31st Oct 2006
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 With Quote
 
=?Utf-8?B?UlN0ZXBo?=
Guest
Posts: n/a
 
      31st Oct 2006
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?

>
>

 
Reply With Quote
 
=?Utf-8?B?QWxsbGxlbg==?=
Guest
Posts: n/a
 
      31st Oct 2006
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?

> >
> >

 
Reply With Quote
 
=?Utf-8?B?UlN0ZXBo?=
Guest
Posts: n/a
 
      31st Oct 2006
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I select 2nd color for two-color gradient fill Office 2007 quattrodom Microsoft Powerpoint 2 18th Jul 2008 05:54 PM
change fill color of a range of cells based on color of a cell? =?Utf-8?B?RGFyTWVsTmVs?= Microsoft Excel Programming 0 2nd Mar 2006 06:35 PM
My fill color and font color do not work in Excel Std Edition 2003 =?Utf-8?B?Y2hhcHN0aWNr?= Microsoft Excel Misc 1 11th Sep 2005 08:48 PM
Excel 2003 will not display color fonts or color fill cells =?Utf-8?B?RGF2ZUM=?= Microsoft Excel Worksheet Functions 1 11th Apr 2005 04:38 PM
My excel 2003 wont let me fill cells with color or color the tabs. =?Utf-8?B?dHJpem9n?= Microsoft Excel New Users 2 22nd Feb 2005 06:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:44 PM.