Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel - Copy Conditional Formatting, Remove Rules, Keep Format

I know you usually show what you've tried in a question, but this is more of a "Do you have a good routine that does this?" question and I'm hoping you'll be willing to let it slide...

I'm working on a macro that copies cells that are conditionally formatted in a source worksheet and pastes them into an output sheet. Basically, I'm looking to keep all the formatting, shading, etc, but remove all the conditions (make the current formatting static) in the output sheet.

I've seen some solutions online - ranging from copying it first to a word document and then pasting it back, to looping through the output cells and copying format-element by format-element - and am just looking for a good, efficient way to do this.

Does anyone have one / a good link they'd be willing to share??

(Excel 2010)

THANKS!!!!

like image 514
John Bustos Avatar asked Sep 10 '14 14:09

John Bustos


People also ask

How do I copy and paste and keep conditional formatting?

Right-click and copy it (or use the keyboard shortcut Control + C) Select the entire range where you want to copy the conditional formatting (C2:C11 in this example) Right-click anywhere in the selection. Click on the Paste Special option.


3 Answers

I think I've got it with the Office Clipboard: Copy range, open the Office Clipboard pane (the tiny button in the bottom right corner of the Clipboard section under the Home tab) and paste from there.

Here's a demo: http://www.bookkempt.com/2017/08/remove-conditional-formatting-but-keep.html

like image 197
MarioTheHedgehog Avatar answered Oct 18 '22 20:10

MarioTheHedgehog


I copied my range of cells. Pasted them into Word. Recopied the range in Word and pasted back into excel.

like image 36
andyw Avatar answered Oct 18 '22 18:10

andyw


Yes it is possible :) What you need to do is change the formatting of the cells that you plan to copy by mimicking the DisplayFormat and then deleting the conditional formatting

Sub Keep_Format()
    Dim ws As Worksheet
    Dim mySel As Range, aCell As Range

    '~~> Change this to the relevant sheet
    Set ws = ThisWorkbook.Sheets("Sheet1")
    '~~> Change this to the relevant range
    Set mySel = ws.Range("A1:A10")

    For Each aCell In mySel
        With aCell
          .Font.FontStyle = .DisplayFormat.Font.FontStyle
          .Interior.Color = .DisplayFormat.Interior.Color
          .Font.Strikethrough = .DisplayFormat.Font.Strikethrough
        End With
    Next aCell

    mySel.FormatConditions.Delete

    '
    '~~> Now Do the copying
    '

    '~~> Once you are done, close the sorce worksheet without saving
End Sub
like image 19
Siddharth Rout Avatar answered Oct 18 '22 20:10

Siddharth Rout