Crues
Crues

Reputation: 165

VBA copying and pasting values and ColumnWidths together

The issue is to paste the copied range into another sheet with the original format (e.g.source columns width to the target column). I have tried to include the code "Paste:=xlPasteColumnWidths" in combination with "Paste:=xlPasteValues". But it wasn't successful. For example, by writing ".PasteSpecial xlPasteColumnWidths" only yields no copied values.

  With wq.Sheets("Table 5").Range("A1:W51").Copy
  End With

  With ws.Range("A6")
 .PasteSpecial xlPasteColumnWidths
  End With

Upvotes: 0

Views: 4425

Answers (1)

Crues
Crues

Reputation: 165

The answer to my question is:

 With wq.Sheets("Table 5").Range("A1:W51").Copy
 ws.Range("A01").PasteSpecial xlPasteAll
 ws.Range("A01").PasteSpecial xlPasteColumnWidths
 ws.Range("A:W").EntireRow.AutoFit
End With

Upvotes: 2

Related Questions