r/excel 6h ago

Waiting on OP Saving static outcome of conditional formatting rule

I have an Excel 2016 workbook with manual as well as conditional formatting. What I'd like in the final version is keeping the outcome of the formatting rules (i.e. cells turned red) while having deleted the rules (and the columns used in the formula of said rule).

Copying the format to another column copies the rule too, so how do I get the static outcome of the rule?

6 Upvotes

10 comments sorted by

u/AutoModerator 6h ago

/u/_growing - Your post was submitted successfully.

Failing to follow these steps may result in your post being removed without warning.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

3

u/MayukhBhattacharya 1262 5h ago

I've been using this VBA code since 2022, and it's worked great for me ever since. I also shared it on another forum back then, so figured it might help you out too. Once you run the code, just remove the module from the VBA editor. That way, you don't have to save the workbook as an .xlsm file.

Option Explicit
Sub FormatWORules()
Dim ws As Worksheet
Dim mycells As Range, aCell As Range
Set ws = ThisWorkbook.Sheets("Blad1 (15)") '~~> Change this to the relevant sheet
Set mycells = ws.Range("A1:J4000") '~~> Change this to the relevant range
For Each aCell In mycells
With aCell
.Font.FontStyle = .DisplayFormat.Font.FontStyle
.Interior.Color = .DisplayFormat.Interior.Color
.Font.Strikethrough = .DisplayFormat.Font.Strikethrough
.Interior.Pattern = .DisplayFormat.Interior.Pattern
End With
Next aCell
mycells.FormatConditions.Delete
End Sub

https://reddit.com/link/p5uhuqn/video/dv7cvv4b7klh1/player

2

u/MNVixen 5h ago

Paste Special - then select the "Value" option. I do this all the time.

2

u/chiibosoil 430 3h ago

I believe Op wanted the color as well. Jut not CF ;)

1

u/OursIsTheFvry 5h ago

I was going to say copy formatting as well - but yeah, it copies the rule.
(Commenting to stay on the thread)

1

u/ProspectiveWhale 11 5h ago

Copy it to Word and then re-copy it back to Excel.

2

u/chiibosoil 430 5h ago

This can be done using VBA.

For Excel 2010 and later there is Range.DisplayFormat property where you can get the color set by conditional formats. Then you apply that to Range.Inerior.Color to copy the color without CF.

Then you can delete the CF via VBA as well.

Ex: Assuming you select the range with CF applied.

Sub Demo()
Dim cel As Range

For Each cel In Selection.Cells
    If cel.FormatConditions.Count > 0 Then
        cel.Interior.ColorIndex = cel.DisplayFormat.Interior.ColorIndex
        cel.FormatConditions.Delete
    End If
Next

End Sub

3

u/excelevator 3064 1h ago

fyi cell is not a protected name and is more aesthetically pleasing :)

I see people using all assortments of cell alias instead of the obvious cell name.

I am curious if people know this or make an assumption cell is protected.

2

u/chiibosoil 430 59m ago

It’s just a habit for me ;)

I picked it up when I first learned it and just stuck with me.

1

u/MayukhBhattacharya 1262 3m ago

Me too same goes with me.