Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ll ll is offline
external usenet poster
 
Posts: 67
Default Excel copy after question

Hi,
I'm very new to the Excel copy after method, and I was wondering how I
would go about integrating the following code into my module. Would I
need to specify the name of the new workbook at some point within the
code? I have tried running the following code by itself in a module,
but I get the "object required" error. Any ideas? Thanks - Louis

==
bk.Worksheets(Array("Hourly Timesheets", "dates", "Time
Balances")).Copy after:=bk.Worksheets(bk.Worksheets.Count)

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Excel copy after question

I ran this several times
Sub Macro1()
Dim bk As Workbook
Set bk = ActiveWorkbook
bk.Worksheets(Array("Hourly Timesheets", _
"dates", "Time Balances")).Copy _
after:=bk.Worksheets(bk.Worksheets.Count)
End Sub

after I created worksheets with the names you show (or at least what the
looked like in the email)


many times, when naming a sheet, you can get an extra space somewhere in the
name, especially at the end. Make sure your sheet names are correct and
match your code.

--
Regards,
Tom Ogilvy



"ll" wrote:

Hi,
I'm very new to the Excel copy after method, and I was wondering how I
would go about integrating the following code into my module. Would I
need to specify the name of the new workbook at some point within the
code? I have tried running the following code by itself in a module,
but I get the "object required" error. Any ideas? Thanks - Louis

==
bk.Worksheets(Array("Hourly Timesheets", "dates", "Time
Balances")).Copy after:=bk.Worksheets(bk.Worksheets.Count)


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Excel copy after question

After you create the new workbook, you can set an object variable to that
workbook.

Dim bk as workbook
'whatevercode you used to create that workbook
'and with that workbook the active workbook.
set bk = activeworkbook
'then lots more code
'and finally, you copy code:
bk.Worksheets(Array("Hourly Timesheets", "dates", "Time Balances")).Copy _
after:=bk.Worksheets(bk.Worksheets.Count)



ll wrote:

Hi,
I'm very new to the Excel copy after method, and I was wondering how I
would go about integrating the following code into my module. Would I
need to specify the name of the new workbook at some point within the
code? I have tried running the following code by itself in a module,
but I get the "object required" error. Any ideas? Thanks - Louis

==
bk.Worksheets(Array("Hourly Timesheets", "dates", "Time
Balances")).Copy after:=bk.Worksheets(bk.Worksheets.Count)


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default Excel copy after question

Check the following items:

1. If this line does not yet exist in your code, add it before the statment
you posted:

Set bk = ActiveWorkbook 'or Set bk=Workbook(yourworkbookname)

2. Check for extra spaces in your sheet names. I noticed a trailing space
in "Time Balances "... if it's absent in the actual sheet name, you would
receive the 'Object required' response from Excel.

--
Jay


"ll" wrote:

Hi,
I'm very new to the Excel copy after method, and I was wondering how I
would go about integrating the following code into my module. Would I
need to specify the name of the new workbook at some point within the
code? I have tried running the following code by itself in a module,
but I get the "object required" error. Any ideas? Thanks - Louis

==
bk.Worksheets(Array("Hourly Timesheets", "dates", "Time
Balances")).Copy after:=bk.Worksheets(bk.Worksheets.Count)


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Misc Excel Copy Question Edward[_3_] Excel Discussion (Misc queries) 6 October 14th 08 01:15 PM
Excel 2003 - copy paste question Ben Excel Discussion (Misc queries) 2 February 21st 08 11:34 PM
QUESTION: Copy pivottable from excel file to another. Simon Excel Discussion (Misc queries) 0 April 26th 06 10:48 AM
copy question Gary Keramidas[_4_] Excel Programming 7 October 8th 05 02:07 AM
question about - excel macro copy chart to word document Jani[_2_] Excel Programming 2 January 16th 04 05:25 PM


All times are GMT +1. The time now is 04:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"