Formatting Range

Daroh

Board Regular
Joined
Aug 19, 2016
Messages
62
Hi, I enter data into a worksheet via a userform and want to apply formatting to range (A:J) on sheet1 if column I (countdown in days) is > 5 (Green), <4.9 but > 2 (Orange) and <1.9 Red. I used conditional formatting but every time I delete a row the formatting does not work for the next row. Thanks for your help.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
The problem is likely in how you set up your format conditions, but you have not posted any information on those. Properly defined, format conditions will not change if if you delete a row. Here's a VBA example which will set up 3 format conditions that seem to match what you have described above.

Code:
Sub SetFormatConditionsColAJ()
    With ActiveSheet.Columns("A:J")
        .FormatConditions.Delete                      'delete old format conditions.

        .FormatConditions.Add Type:=xlExpression, Formula1:="=$I1 < 1.9"
        .FormatConditions(.FormatConditions.count).SetFirstPriority
        .FormatConditions(1).Interior.Color = RGB(255, 0, 0)

        .FormatConditions.Add Type:=xlExpression, Formula1:="=AND($I1 >=1.9,$I1 <= 5)"
        .FormatConditions(.FormatConditions.count).SetFirstPriority
        .FormatConditions(1).Interior.Color = RGB(255, 165, 0)

        .FormatConditions.Add Type:=xlExpression, Formula1:="=$I1 > 5"
        .FormatConditions(.FormatConditions.count).SetFirstPriority
        .FormatConditions(1).Interior.Color = RGB(0, 128, 0)
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,265
Members
452,627
Latest member
KitkatToby

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