1

Below code copies data(as well as formatting) from source range to target range.

Set RngTemplate = ActiveWorkbook.Worksheets("Template").Range("A1:AD1")
Set RngTarget = ActiveWorkbook.Worksheets("File1").Range("A1:AD1")   
RngTemplate.Copy RngTarget

But I also want the cell widths to be copied to target range, any idea how to implement it.

1 Answer 1

1

Use the .PasteSpecial() method

Set RngTemplate = ActiveWorkbook.Worksheets("Template").Range("A1:AD1")
Set RngTarget = ActiveWorkbook.Worksheets("File1").Range("A1:AD1")   
RngTemplate.Copy
RngTarget.PasteSpecial
RngTarget.PasteSpeical xlPasteColumnWidths
Application.CutCopyMode = False
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.