ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy Column Width (https://www.excelbanter.com/excel-programming/444538-re-copy-column-width.html)

Steve[_4_]

Copy Column Width
 
Hi Garry,

I'm getting an "expected end statement" on this line:
.UsedRange.Copy wksTarget.range("1:1").PasteSpecial xlPasteColumnWidths

within this subset of code:
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

On Wednesday, May 4, 2011 2:03:34 PM UTC-6, GS wrote:
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

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc



GS[_2_]

Copy Column Width
 
After serious thinking Steve wrote :
Hi Garry,

I'm getting an "expected end statement" on this line:
.UsedRange.Copy wksTarget.range("1:1").PasteSpecial xlPasteColumnWidths

within this subset of code:
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

On Wednesday, May 4, 2011 2:03:34 PM UTC-6, GS wrote:
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

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc


Steve,
That's supposed to be 2 separate lines. Your trying to infer the
destination and you can't do that with PasteSpecial. So either put it
back the way I posted it OR separate the two with a colon.

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc




All times are GMT +1. The time now is 01:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com