Nov 15 2017 12:21 AM
Hi,
I sometimes use conditional formatting. For each entry, there's a cell range that it applies to. Often I need it to be used on the entire sheet, or at least a large range of it, i.e. all rows that have content.
But then I need to insert or remove data, and that mucks up the range. It seems to copy the entry to the range above, the inserted range, and the range below. I want it to keep the range and entries as they are when I edit the sheet's data.
How?
I usually enter the range as e.g. $1:$1048576 or $A:$XFD.
Nov 15 2017 03:43 AM
Jan 05 2018 10:35 AM
That doesn't work in Excel 2016. I'm wondering if there is a way to set the "Applies to" field to a named range vs. $A:$A.
Jan 07 2018 10:43 AM
Jan 24 2018 07:28 PM
Jan 17 2019 11:06 AM
This doesn't work - when a named range is referred to, it immediately evaluates it, so using a named range is equivalent to entering the definition of said range.
One thing I've found in my spreadsheet is that inserting a row only affects one conditional formatting entry (probably because this is the only one which uses a formula, one which refers to other surrounding cells). Nonetheless this is annoying as the 'Manage Rules' dialog is difficult enough to use (you can't even resize?!) without rules being spawned with every spreadsheet edit.
Jul 03 2021 06:34 AM
Jul 30 2021 08:20 AM
Jul 30 2021 10:02 AM
Aug 22 2021 09:08 PM - edited Aug 23 2021 04:25 PM
I have been experimenting with a rough workaround for this problem that applies if you only need to insert new rows OR columns but not both
If you set the conditional format range as entire rows eg ($5:$50), you can then insert new rows within this range to automatically expand it to ($5:$51) without it breaking into pieces. But:
- It only works for conditional formats based on a formula; however, you can mimic (for example) traffic light icons by using character "l" in the Wingdings font and then applying a custom number format of l;l;l;@ on the required range. This forces the values 1, 0 and -1 to all display a filled circle, with the ability to then use conditional formatting to change the colour based on the underlying number value
- You will likely need to include an AND statement in every conditional format formula to stop it from formatting cells in unwanted columns outside your desired range. eg = AND(A$1="Y") and put "Y" in row 1 for all columns that require the format
- Select "Stop if true" on each formula to help improve performance
- The approach will only work on either Rows OR Columns. For example switch to a range of (say) $B:$Z if you wish to add columns within this range
Aug 22 2021 10:53 PM
Interesting that you apply CF to entire sheets (entire rows/columns also works). In my experience that is a very unusual practice but one that appears to work in that it does not expand the used range or appear particularly resource intensive. I fully agree that it is a pain that this antiquated bit of functionality will not accept a named range as the range to which the formatting is applied but, instead, follows its own rules to generate collections of individual cells.
Because of the way in which CF works, it appears to be perfectly normal for the .AppliesTo range to look like something the dog has chewed. Constant repair seems to be called for!
You won't have encountered it yet, but the inability of CF to recognise dynamic array ranges is also a severe limitation. I think Microsoft is aware that conditional formatting falls well short of expectations, but the code base appears to be ancient and will require a huge amount of effort to rectify its shortcomings.
Aug 30 2021 08:05 AM
I don't apply CF to entire sheets. Only ranges within the sheet.
Sep 01 2021 01:51 AM
Sep 03 2021 06:19 AM
The simplest workaround is to create own function which will return required range.
In my case it was whole column, but you can make more complex versions of it, for example specific range like "B1:B15".
Function GetColumn(columnName As String)
GetColumn = ActiveSheet.Range(columnName + ":" + columnName)
End Function
Next, in CFR Manager you are going to indicate required range by using the formula:
Now, you can copy, insert, delete rows, but excel won't crumble it.
Sep 15 2021 01:52 AM - edited Sep 15 2021 02:05 AM
Thank for this idea !
However, I tried it, and when I click "apply" on the CF window manager, my initial range is still displayed, as if my entry was not valid.
Before
After
And the formula is working..
Any idea what I got wrong ?
I tried also to use "INDIRECT" function, but excel just evaluated the range when applied.
Thank you !
Dec 10 2021 02:06 AM
Dec 29 2021 11:06 PM
Jan 26 2022 09:47 PM
Solution
Was having the same issue and so my search led to this forum, searched everywhere else and couldn't find the answer, played around with it and finally figured it out. It's actually a pretty simple solution.
Instead of Inserting a column or copying and inserting a column, all you have to do is select the column cells that you want to extend, then at the bottom of the cursor where the plus sign is, click and drag to the right as many columns as needed.
The CF range extended to the last column without creating any extra conditions or messing up the original range.
Mar 10 2022 01:29 AM
Microsoft, couldn't you just add an optional fixed flag to the range option? Everyone is sick of this issue, and the only workaround I've ever found is to use event to re-establish the range, which his just daft.
May 19 2022 05:02 AM
Jan 26 2022 09:47 PM
Solution
Was having the same issue and so my search led to this forum, searched everywhere else and couldn't find the answer, played around with it and finally figured it out. It's actually a pretty simple solution.
Instead of Inserting a column or copying and inserting a column, all you have to do is select the column cells that you want to extend, then at the bottom of the cursor where the plus sign is, click and drag to the right as many columns as needed.
The CF range extended to the last column without creating any extra conditions or messing up the original range.