Color row in Report based on Condition of Cells in a Column

CW Moss

New Member
Joined
Nov 29, 2005
Messages
18
Hello,

Could someone please help me.
I would like the color of an entire row change if the condition in column B (Duration Hour) matches the criteria below in a Access 2003 Report.

If B is less than 12 then then row is remains white
If B is between 12and 24 then the row is highlighted yellow
If B is greater than 24 then the row is highlighted red

I tried to paste in an example below but only the text displayed.

A____________B
Process__Duration Hours
1 AT31___ 187.7 Row should be Highlighted Red

2 AT32___ 261.2 Row should be Highlighted Red

3 AT33___ 4 No Highlight

4 AT34___ 493.53 Row should be Highlighted Red

5 AT35___ 11.99 No Highlight

6 AT36___ 18.2 Row should be Highlighted Yellow

7 AT37___ 640.7 Row should be Highlighted Red

8 AT47___ 33.7 Row should be Highlighted Red

9 AT48___ 3.7 No highlight

10 AT49__ 1594.7 Row should be Highlighted Red

11 AT50__ 12 Row should be Highlighted Yellow

12 AT51__ 23.7 Row should be Highlighted Red

Thanks for your help in advanced.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
What you need to do is put code in the Format event of the Detail section of the report.

Perhaps something like this.
Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Select Case DurationHours
        Case > 24
             Detail.BackColor = vbRed
        Case 12 to 24 
             Detail.BackColor = vbYellow
        Case Else
             Detail.BackColor = 16777215
    End Select
End Sub
 
Upvote 0
Norie,

Perfect, I ran a quick test and it appears to do just what is needed. I had to make two small adjustments as follows;

Case >= 24

Case 12 to 23.99

Hopefully one day I will be able to return the favor to you or at least pass what I have learned on to someone in need.

Again Thanks
 
Upvote 0

Forum statistics

Threads
1,224,269
Messages
6,177,563
Members
452,784
Latest member
talippo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top