abiedermann
abiedermann

Reputation: 63

VBA to use Format Painter to copy format from Column to Column

For part of a VBA I am writing I need to copy the format for all of Column I into all of Column J. I figure I should use the format painter. I know this should be easy but I have never done any VBA for format painting, can anyone advise? Again, need to copy format from Column I to the next column (J). Thanks in advance!

Upvotes: 3

Views: 27154

Answers (1)

paul bica
paul bica

Reputation: 10715

Recorded a macro and adjusted it for the UsedRange only:

Public Sub copyColFormat()

    With Worksheets("Sheet1").UsedRange

        .Columns("I").Copy
        .Columns("J").PasteSpecial Paste:=xlPasteFormats

        .Cells(1).Select
    End With

    Application.CutCopyMode = False

End Sub

Upvotes: 5

Related Questions