Copy Column Width

S

Steve

Hello. I'm copying a range of cells with the code below to a different worksheet. How can I modify the code to also copy over the column widths from the source page? Thanks!

With wksSource
.Columns("K:K").AutoFilter Field:=1, Criteria1:="Y"
.UsedRange.Copy wksTarget.Rows("1:1")
.Columns("K:K").AutoFilter
End With
 
G

GS

Steve has brought this to us :
Hello. I'm copying a range of cells with the code below to a different
worksheet. How can I modify the code to also copy over the column widths
from the source page? Thanks!

With wksSource
.Columns("K:K").AutoFilter Field:=1, Criteria1:="Y"
.UsedRange.Copy wksTarget.Rows("1:1")
.Columns("K:K").AutoFilter
End With

Try...

With wksSource
.Columns("K:K").AutoFilter Field:=1, Criteria1:="Y"
.UsedRange.Copy
wksTarget.Range("1:1").PasteSpecial xlPasteColumnWidths
.UsedRange.Copy wksTarget.Range("1:1") '//put the data
.Columns("K:K").AutoFilter
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top