Excel – Copy conditional formatting from one cell to another using VBA

excelvba

Can I copy conditional formatting from one cell to another using VBA?

I'm imagining something like:

Sheets("A").Range("A1:A10").ConditionalFormatting = Sheets("B").Range("B1").ConditionalFormatting

Best Solution

use this:

Sub test()
     Sheets("B").[B1].Copy: Sheets("A").[A1:A10].PasteSpecial xlPasteFormats
End Sub
Related Question