-
can't paste content
[VBA]
Sub test()
Dim i As Integer
Dim Header As Variant
Application.ScreenUpdating = False
'write array values
Header = Array("Franchise Code", "Account", "Name", "1-15 Days", "16-25 Days", "26-30 Days", "31-40 Days" _
, "41-45 Days", "46-60 Days", "61-90 Days", "91-120 Days", "Over 120 Days", "Total", "Terms")
Range("A:A").End(xlDown).Select
Range(Selection, Selection.End(xlDown)).EntireRow.Copy
'create headers on Licensing tab
For i = 1 To UBound(Header)
Worksheets("Licensing").Cells(1, i).Value = Header(i)
Next i
'paste copied content
Worksheets("Licensing").Paste (Range("A2"))
End Sub
[/VBA]
Everything goes well untill i get to "'paste copied content
" part. Necessary content is copied, headers on Licensing tab are created, when i get to paste part it's saying: "Run time error 1004 / Paste method of worksheet class failed.", i'm totally stuck, help file didn't help me. Any suggestions?
Thanks.
-
You're trying to paste an entire column into a smaller area.
Try
[VBA]
Sub test()
Dim i As Integer
Dim Header As Variant
Application.ScreenUpdating = False
'write array values
Header = Array("Franchise Code", "Account", "Name", "1-15 Days", "16-25 Days", "26-30 Days", "31-40 Days" _
, "41-45 Days", "46-60 Days", "61-90 Days", "91-120 Days", "Over 120 Days", "Total", "Terms")
'create headers on Licensing tab
Worksheets("Licensing").Cells(1, 1).Resize(, UBound(Header) + 1).Value = Header
'paste copied content
Range(Range("A2"), Range("A2").End(xlDown)).EntireRow.Copy Worksheets("Licensing").Range("A2")
End Sub
[/VBA]
-
[vba]
Dim i As Integer
Dim Header As Variant
Application.ScreenUpdating = False
'write array values
Header = Array("Franchise Code", "Account", "Name", "1-15 Days", "16-25 Days", "26-30 Days", "31-40 Days" _
, "41-45 Days", "46-60 Days", "61-90 Days", "91-120 Days", "Over 120 Days", "Total", "Terms")
Range("A:A").End(xlDown).Select
Range(Selection, Selection.End(xlDown)).EntireRow.Copy Worksheets("Licensing").Range("A2")
'create headers on Licensing tab
For i = 1 To UBound(Header)
Worksheets("Licensing").Cells(1, i).Value = Header(i)
Next i
[/vba]
-
Thank you that worked perfectly!