Using Offset or Indirect in \'Applies To\' does not seem to work. Is there any other way to stop conditional formatting from breaking after inserting row/s
I know this is an old thread but here's another solution that's super simple and works great.
Simply insert a new row or column as desired. Then select and copy a row/column that has the correct conditional formatting. Past Special into the new row/column that you just created and select the option for "All merging conditional formats". Your conditional formatting rules should now be automatically updated.
Happy Excel-ing =)
I realized that insert row is not causing the splitting of the conditional formatting rules. I also copy a row and paste in the inserted row which is doing this. If I opt for special paste and choose formulas only, its working fine.
However, I wonder if there would ever be a need to use 'INDIRECT' or 'OFFSET' in 'Applies to' field of Conditional Formatting. If so, it's going to be a problem.
This worked well enough for me...
Sub ConditionalFormattingRefresh()
'
' ConditionalFormattingRefresh Macro
'
'Generales
Dim sh As Worksheet
Dim tbl As ListObject
Dim selectedCell As Range
Set sh = ActiveSheet
Set tbl = Range("Plan").ListObject
Set selectedCell = ActiveCell
'Rango a copiar
Dim copyRow As Range
Set copyRow = tbl.ListRows(1).Range
'Rango a restaurar
Dim startCell As Range
Dim finalCell As Range
Dim refreshRange As Range
Set startCell = tbl.DataBodyRange.Cells(2, 1)
Set finalCell = tbl.DataBodyRange.Cells(tbl.ListRows.Count, tbl.ListColumns.Count)
Set refreshRange = Range(startCell.Address, finalCell)
'Ocultar procesamiento
Application.ScreenUpdating = False
Application.EnableEvents = False
'Borrar formato corrupto
refreshRange.FormatConditions.Delete
'Copiar
copyRow.Copy
'Pegar formato
tbl.DataBodyRange.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
'Retornar a la normalidad
selectedCell.Select
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
I have found a simple process that seems to work consistently for inserting new rows or columns AND preserves the continuity of the conditional formatting rules (in Office 2010 at least), as follows:
NOTE a) Your conditional formatting is automatically applied to the inserted rows or columns without you having to do anything further. The formatting should have been inherited from the neighboring row or column. b) Any borders formatting should also have been copied to the newly inserted cells.
Select a row, column or range (by clicking it) that is adjacent to the newly inserted ones, and which contains the conditional formatting (and formulas and data if applicable) to be copied.
Hover your mouse over the lower left or lower right corner of the selected range until you see a plus "+" sign appear (don't confuse it with the row re-size gadget as they look similar).
Left click and hold on "+", and drag across the desired rows, columns or range to be formatted, then release.
NOTE: I create Conditional Formatting rules referencing only one cell: Example) in the field titled "Format values where this formula is true:", create a rule such as ... =AND($B8="",$C8="",$D8="",$K8<>""), where this rule Applies to say the range ... =$B$8:$D$121,$J$8:$M$121.
I got it to work on Excel Mac 2011 by the following steps
The CF rules stayed unsplit and updated to include an additional row.
Here's a similar thread that may get you ont he right track:
How to use the Worksheet_Change event for Conditional Formatting?
It outlines a workaround to R1C1 style formatting which may not be affected by the inserts (untested) along with the VBA approach I mentioned in the comments.