Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

paste special xlcolumnwidth

Status
Not open for further replies.

jmnekrkt

Programmer
Feb 21, 2002
47
US
recorded macro code:
Range("A2").Select
Selection.PasteSpecial Paste:=xlColumnWidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

My code:

Sub Calstars()
Dim myRange As Range
Worksheets("CalstarsReport").Range("Calstars").Copy
Workbooks.Add (xlWBATWorksheet)
With Workbooks(2).Worksheets(1)
.Cells(.UsedRange.Cells(.UsedRange.Cells.Count).Row + 1, 1).PasteSpecial xlValues
End With
Workbooks(2).Worksheets(1).UsedRange.PasteSpecial xlFormats
Range("A2").Select
Selection.PasteSpecial Paste:=xlColumnWidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End Sub

My code dies w/

runtime error "1004"/Application defined or object defined error

on the last line of code where I tell it to paste special. I can manually go to cell a2 and pastespecial/columnwidths and it works fine.

Please advise.

Thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top