Auto-expand conditional formatting range to include new columns/rows

jake020

New Member
Joined
Mar 4, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I like to apply conditional formatting when tracking metrics to quickly identify things such as top and bottom 3 months of performance, however, whenever I add a new month (typically as a new column) the formatting does not include the new data, so I need to manually change the Applies To range for each item. This can take a long time since there are a lot of metrics to track and this needs to be done each month. Using the Format Painter also doesn't seem to solve the issue since that will usually apply the same Rule to the new column but will only apply to that column. So for instance, I will have a rule highlight Top 1 that Applies To $C$3:$H$3 and if I add data to column J and use Format Painter, I will still have a rule highlighting Top 1 for cells $C$3:$H$3 but will then also have a rule highlighting Top 1 for cell J3.

Is there any way to make it so that the conditional formatting rule will automatically expand the Applies To range to include data entered in a new column?
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Welcome to the Board

Are you familiar with VBA?

VBA Code:
' sheet module
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i%, fc
For i = 1 To Target.Parent.UsedRange.FormatConditions.count
    Set fc = Target.Parent.UsedRange.FormatConditions(i)
    If Not Intersect(fc.AppliesTo, Target.EntireRow) Is Nothing And Len(Target) _
    Then fc.ModifyAppliesToRange Union(fc.AppliesTo, Target)
Next
End Sub
 
Upvote 0
Unfortunately I'm not too experienced with VBA, is there any other way to achieve this?
 
Upvote 0
For automated behavior, no. Try the workbook below, which implements the code I posted before.

Adding data to the right will expand the conditional formatting.

 
Upvote 0
use range 1:1000, it may change to full range (A1:AZ1000, or something like that), but it will update as you add more lines or columns, so it will stay full range
 
Upvote 0

Forum statistics

Threads
1,214,626
Messages
6,120,602
Members
448,974
Latest member
ChristineC

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