Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Save Worksheet To Master Workbook

Hi
Can I create a macro to save a weekly Worksheet to a Master Workbook? The
Master is held on a Network Drive and the weekly Worksheet has a unique tab
name, e.g each week the new worksheet will be named Week 1, Week 2..etc for
52 weeks of the year so at the end of the year there will be 52 individual
worsheets within the Master Workbook.
Thanks in advance
Bobzter
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 33
Default Save Worksheet To Master Workbook

I'm not 100% sure I understand exactly what you need, but here's what I'm
thinking. You want some VBA which will open up a master workbook, copy the
current worksheet into that workbook, and then save and close the master
workbook. So, for example, if you're working on the Week 17 sheet, it will
automatically copy Week 17 into the master workbook.

Let me know if I didn't understand correctly, but the following code does
that. You'll need to change the name and location of your Master workbook.

Sub CopyActiveSheet()

Dim strWeekly As String

strWeekly = ActiveWorkbook.Name

Workbooks.Open Filename:="D:\my documents\Master.xlsb"
Windows(strWeekly).Activate
ActiveSheet.Copy
After:=Workbooks("Master.xlsb").Sheets(Workbooks(" Master.xlsb").Sheets.Count)
Windows("Master.xlsb").Activate
ActiveWorkbook.Save
ActiveWindow.Close
End Sub


--
Happy calculating!

If you like this answer, please click ''Yes.''




"Bobzter100" wrote:

Hi
Can I create a macro to save a weekly Worksheet to a Master Workbook? The
Master is held on a Network Drive and the weekly Worksheet has a unique tab
name, e.g each week the new worksheet will be named Week 1, Week 2..etc for
52 weeks of the year so at the end of the year there will be 52 individual
worsheets within the Master Workbook.
Thanks in advance
Bobzter

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Save Worksheet To Master Workbook

Hi
thanks for your reply.
I'm getting a syntax error on the following line (error highlighted on
After:=Workbooks)

After:=Workbooks("Master.xlsb").Sheets(Workbooks(" Master.xlsb").Sheets.Count)

This is the altered code I'm using

Sub CopyActiveSheet()

Dim strWeekly As String

strWeekly = ActiveWorkbook.Name

Workbooks.Open Filename:="D:\my documents\Master.xlsb"
Windows(strWeekly).Activate
ActiveSheet.Copy
After:=Workbooks("Master.xlsb").Sheets(Workbooks(" Master.xlsb").Sheets.Count)
Windows("Master.xlsb").Activate
ActiveWorkbook.Save
ActiveWindow.Close
End Sub

Best Regards

bobzter

"GSnyder" wrote:

I'm not 100% sure I understand exactly what you need, but here's what I'm
thinking. You want some VBA which will open up a master workbook, copy the
current worksheet into that workbook, and then save and close the master
workbook. So, for example, if you're working on the Week 17 sheet, it will
automatically copy Week 17 into the master workbook.

Let me know if I didn't understand correctly, but the following code does
that. You'll need to change the name and location of your Master workbook.

Sub CopyActiveSheet()

Dim strWeekly As String

strWeekly = ActiveWorkbook.Name

Workbooks.Open Filename:="D:\my documents\Master.xlsb"
Windows(strWeekly).Activate
ActiveSheet.Copy
After:=Workbooks("Master.xlsb").Sheets(Workbooks(" Master.xlsb").Sheets.Count)
Windows("Master.xlsb").Activate
ActiveWorkbook.Save
ActiveWindow.Close
End Sub


--
Happy calculating!

If you like this answer, please click ''Yes.''




"Bobzter100" wrote:

Hi
Can I create a macro to save a weekly Worksheet to a Master Workbook? The
Master is held on a Network Drive and the weekly Worksheet has a unique tab
name, e.g each week the new worksheet will be named Week 1, Week 2..etc for
52 weeks of the year so at the end of the year there will be 52 individual
worsheets within the Master Workbook.
Thanks in advance
Bobzter

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Save Worksheet To Master Workbook

Hi

Messed around with the code and have copied my final below. Sorry - i still
get the same failure. I'm testing this on Excel 2007 but will run it on Excel
2003. Please note that the same failure comes up on both 2003 and 2007.

Sub SaveTester()
'
' SaveTester Macro
Dim strWeekly As String

strWeekly = ActiveWorkbook.Name

Workbooks.Open Filename:="L:\Testbook.xlsx"
Windows(strWeekly).Activate
ActiveSheet.Copy
After =
Workbooks("Testbook.xlsx").Sheets(Workbooks("Testb ook.xlsx").Sheets.Count)
Windows("Testbook.xlsx").Activate
ActiveWorkbook.Save
ActiveWindow.Close


End Sub

thank you for the time, again.

Regards
Bobzter

"Bobzter100" wrote:

Hi
thanks for your reply.
I'm getting a syntax error on the following line (error highlighted on
After:=Workbooks)

After:=Workbooks("Master.xlsb").Sheets(Workbooks(" Master.xlsb").Sheets.Count)

This is the altered code I'm using

Sub CopyActiveSheet()

Dim strWeekly As String

strWeekly = ActiveWorkbook.Name

Workbooks.Open Filename:="D:\my documents\Master.xlsb"
Windows(strWeekly).Activate
ActiveSheet.Copy
After:=Workbooks("Master.xlsb").Sheets(Workbooks(" Master.xlsb").Sheets.Count)
Windows("Master.xlsb").Activate
ActiveWorkbook.Save
ActiveWindow.Close
End Sub

Best Regards

bobzter

"GSnyder" wrote:

I'm not 100% sure I understand exactly what you need, but here's what I'm
thinking. You want some VBA which will open up a master workbook, copy the
current worksheet into that workbook, and then save and close the master
workbook. So, for example, if you're working on the Week 17 sheet, it will
automatically copy Week 17 into the master workbook.

Let me know if I didn't understand correctly, but the following code does
that. You'll need to change the name and location of your Master workbook.

Sub CopyActiveSheet()

Dim strWeekly As String

strWeekly = ActiveWorkbook.Name

Workbooks.Open Filename:="D:\my documents\Master.xlsb"
Windows(strWeekly).Activate
ActiveSheet.Copy
After:=Workbooks("Master.xlsb").Sheets(Workbooks(" Master.xlsb").Sheets.Count)
Windows("Master.xlsb").Activate
ActiveWorkbook.Save
ActiveWindow.Close
End Sub


--
Happy calculating!

If you like this answer, please click ''Yes.''




"Bobzter100" wrote:

Hi
Can I create a macro to save a weekly Worksheet to a Master Workbook? The
Master is held on a Network Drive and the weekly Worksheet has a unique tab
name, e.g each week the new worksheet will be named Week 1, Week 2..etc for
52 weeks of the year so at the end of the year there will be 52 individual
worsheets within the Master Workbook.
Thanks in advance
Bobzter

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Save Worksheet To Master Workbook

Hi

Of course, you'll be asking what fool am I!
I corrected the code by moving Activesheet.Copy After... onto the same line.
I had taken a copy from your post and it had split the single line into 2.
Many thanks - the code works perfectly!
Cheers
Bobzter

"Bobzter100" wrote:

Hi

Messed around with the code and have copied my final below. Sorry - i still
get the same failure. I'm testing this on Excel 2007 but will run it on Excel
2003. Please note that the same failure comes up on both 2003 and 2007.

Sub SaveTester()
'
' SaveTester Macro
Dim strWeekly As String

strWeekly = ActiveWorkbook.Name

Workbooks.Open Filename:="L:\Testbook.xlsx"
Windows(strWeekly).Activate
ActiveSheet.Copy
After =
Workbooks("Testbook.xlsx").Sheets(Workbooks("Testb ook.xlsx").Sheets.Count)
Windows("Testbook.xlsx").Activate
ActiveWorkbook.Save
ActiveWindow.Close


End Sub

thank you for the time, again.

Regards
Bobzter

"Bobzter100" wrote:

Hi
thanks for your reply.
I'm getting a syntax error on the following line (error highlighted on
After:=Workbooks)

After:=Workbooks("Master.xlsb").Sheets(Workbooks(" Master.xlsb").Sheets.Count)

This is the altered code I'm using

Sub CopyActiveSheet()

Dim strWeekly As String

strWeekly = ActiveWorkbook.Name

Workbooks.Open Filename:="D:\my documents\Master.xlsb"
Windows(strWeekly).Activate
ActiveSheet.Copy
After:=Workbooks("Master.xlsb").Sheets(Workbooks(" Master.xlsb").Sheets.Count)
Windows("Master.xlsb").Activate
ActiveWorkbook.Save
ActiveWindow.Close
End Sub

Best Regards

bobzter

"GSnyder" wrote:

I'm not 100% sure I understand exactly what you need, but here's what I'm
thinking. You want some VBA which will open up a master workbook, copy the
current worksheet into that workbook, and then save and close the master
workbook. So, for example, if you're working on the Week 17 sheet, it will
automatically copy Week 17 into the master workbook.

Let me know if I didn't understand correctly, but the following code does
that. You'll need to change the name and location of your Master workbook.

Sub CopyActiveSheet()

Dim strWeekly As String

strWeekly = ActiveWorkbook.Name

Workbooks.Open Filename:="D:\my documents\Master.xlsb"
Windows(strWeekly).Activate
ActiveSheet.Copy
After:=Workbooks("Master.xlsb").Sheets(Workbooks(" Master.xlsb").Sheets.Count)
Windows("Master.xlsb").Activate
ActiveWorkbook.Save
ActiveWindow.Close
End Sub


--
Happy calculating!

If you like this answer, please click ''Yes.''




"Bobzter100" wrote:

Hi
Can I create a macro to save a weekly Worksheet to a Master Workbook? The
Master is held on a Network Drive and the weekly Worksheet has a unique tab
name, e.g each week the new worksheet will be named Week 1, Week 2..etc for
52 weeks of the year so at the end of the year there will be 52 individual
worsheets within the Master Workbook.
Thanks in advance
Bobzter



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 33
Default Save Worksheet To Master Workbook

Bob,

Glad you got it to work. Actually, when I pasted it, I thought about that
and wondered if the word wrap would get you. Sorry about that!

Enjoy! If you could hit "Yes" on the post to mark this one as answered that
would be helpful as well.

Have a great one!


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
Update worksheet from Master workbook txheart Excel Discussion (Misc queries) 1 August 14th 08 05:12 PM
Update worksheet from Master workbook txheart Excel Discussion (Misc queries) 0 August 13th 08 09:17 PM
save information from several worksheets to a master worksheet nicktjr Excel Discussion (Misc queries) 1 July 1st 08 07:16 PM
How do I save a worksheet within a workbook? jester Excel Discussion (Misc queries) 1 August 7th 06 10:54 PM
How do I set up a Workbook with a master compiled worksheet and o. Double D Racing Excel Worksheet Functions 1 November 19th 04 06:03 AM


All times are GMT +1. The time now is 04:15 AM.

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

About Us

"It's about Microsoft Excel"