Copy Column Width

  • Thread starter Thread starter Steve
  • Start date Start date
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
 
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
 
Back
Top