MartyConnelly
martyconnelly at shaw.ca
Tue Sep 12 14:24:55 CDT 2006
Use the Object Browser Luke!
There is more than one copy method
or it maybe you haven't set the activesheet
in your method
Sub CopyAndName()
' This creates a new sheet,
' copies the data from the first sheet,
Dim sName As String, sht1 As Worksheet, sht2 As Worksheet
Set sht1 = ActiveSheet
Set sht2 = Worksheets.Add(after:=ActiveSheet)
sht2.Name = "MyNewName "
sht1.UsedRange.Copy Destination:=sht2.Range("A1")
End Sub
Billy Pang wrote:
>Hello:
>
>>From Access, I'm trying to make a copy of a worksheet within an instance of
>Excel that is created at runtime in VBA.
>
>xlsheet.copy after:=activesheet
>
>However, I get the following error message.
>
>Run-time error '5'
>
>Invalid procedure call or argument
>Any ideas?
>
>Many thanks in advance,
>Billy
>
>
>
--
Marty Connelly
Victoria, B.C.
Canada