Conditional Formatting Issue

jegentry

New Member
Joined
Nov 1, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Good Afternoon!

I am having trouble creating a conditional format that changes the cell colors based on a running total. Such that, when the total reaches 600 hours the format changes to another color. The problem is there will never be a time when the hours can be esxactly 600. How do I create a conditional format either in VBA or thru the "new rule" to format the hours from 1 to 600 with one type of formatting and then the hours between 601 to 1200 with another type of formatting? My cells are non-adjacent and thi is a calendar of sorts. please see pic for example. I want the cell that goes over 600 to have a gradient from the 1st format to move into the new format assocaite with hours between 601 and 1200.
Example1.jpg
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
If anyone is interested I found my own answer and put it into VBA Code. If anyone has a more elegant solution I am still interested in another way to do this. Please see below:

VBA Code:
Sub colorize()
Dim myrow As Integer, mycol As Integer, counter As Integer
colstart = 7: colend = 37
rowstart = 11: rowend = 12


start:
For mycol = colstart To colend

    For myrow = rowstart To rowend
    
                counter = counter + Cells(myrow, mycol).Value
                
                    If counter <= 600 Then
                            If Cells(myrow, mycol).Value >= 1 Then
                                ' Color Green ------------------------------------------------
                                With Cells(myrow, mycol).Interior
                                    .Pattern = xlSolid
                                    .PatternColorIndex = xlAutomatic
                                    .ThemeColor = xlThemeColorAccent6
                                    .TintAndShade = 0.599993896298105
                                    .PatternTintAndShade = 0
                                End With
                            End If
                    
                    ElseIf counter >= 601 And counter <= 1200 Then
                            If Cells(myrow, mycol).Value >= 1 Then
                                ' Color Blue ------------------------------------------------
                                With Cells(myrow, mycol).Interior
                                    .Pattern = xlSolid
                                    .PatternColorIndex = xlAutomatic
                                    .ThemeColor = xlThemeColorAccent5
                                    .TintAndShade = 0.599993896298105
                                    .PatternTintAndShade = 0
                                End With
                            End If
                    
                    ElseIf counter >= 1201 Then
                            If Cells(myrow, mycol).Value >= 1 Then
                                ' Color Orange ------------------------------------------------
                                With Cells(myrow, mycol).Interior
                                    .Pattern = xlSolid
                                    .PatternColorIndex = xlAutomatic
                                    .ThemeColor = xlThemeColorAccent4
                                    .TintAndShade = 0.599993896298105
                                    .PatternTintAndShade = 0
                                End With
                            End If
                    
                    End If
    Next myrow

Next mycol

colstart = 7
rowstart = rowstart + 5
rowend = rowend + 5

If rowstart > 67 Then Exit Sub Else GoTo start


End Sub
 

Attachments

  • SolutionPic.jpg
    SolutionPic.jpg
    175 KB · Views: 4
Upvote 0

Forum statistics

Threads
1,214,789
Messages
6,121,590
Members
449,039
Latest member
Arbind kumar

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