Macro Move Sheets

Packfan86

New Member
Joined
Jun 24, 2008
Messages
26
Hey everybody,


I have about 80 sheets in a workbook, and I would like to put each sheet into it's own workbook, and have that new workbook called by the value in Column A. Does anybody know how I would do this?

Thanks in advance!
 
I'm not your girl for that one - haven't used 2007 yet. Would suggest you start a new thread for it anyway - then you'll get people who know about Pivot Charts to look at it! (You can link it here if you want.)

One thought - the PDF of MrExcel's latest book is free to download from this site (can't remember exactly where) - it's got a whole big section on Pivot Tables in 2007, so may have the answer to your question.
 
Upvote 0

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
I'm not an 07 user either I'm afraid.

CG - idiosyncratic or brilliant... hmm... inefficient probably best describes me.
(and I didn't say my method was good.. just different...)
 
Upvote 0
Stop putting yourself down ;)
I just want to know why you did it like that, because it wouldn't have occurred to me!
 
Upvote 0
Hi guys,

This is very close to a solution I'm looking for...

I have a macro that runs at midnight, and also when the workbook is opened: It checks to see if a worksheet for the month exists (Aug 08), and if it doesn't, it copies a worksheet called "Template", and renames it to the current month and year (tomorrow it will create a worksheet called "Sep 08").

What I would like to happen now, is when a new worksheet is created, it would take last month's worksheet, copy it into another workbook in another directory, and rename the workbook to the name of the sheet that was copied. So tonight at midnight, I want the macro to move "Aug 08" to a new workbook and call that workbook the same name.

Would that be much of a modification to this code?

Thanks in advance,

-Brian
 
Upvote 0
Last edited:
Upvote 0
Something like:

Code:
Sub SaveWS()
Dim wb As Workbook
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
    ws.Copy
    Set wb = ActiveWorkbook
    wb.SaveAs ThisWorkbook.Path & ws.Range("A1").Value & ".xls"
    wb.Close False
Next ws
End Sub

(based on this thread: http://www.mrexcel.com/forum/showthread.php?t=321719)


I really like this code. I've adjusted to this:

Sub SaveWS()
Dim wb As Workbook
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Copy
Set wb = ActiveWorkbook
wb.SaveAs ThisWorkbook.Path & ws.Range("A8").Value & " " & ws.Name & ".xls"
wb.Close False
Next ws
End Sub

... but would like for the new sheets to be saved in the same folder as the original & not have (in my case) "20081230" at the beginning of the file name (the file name should only incl value in A8 and the ws.Name). Can anybody help?
 
Upvote 0
not entirely sure I'm following you're saying file name should be the combination of Range(A8) and worksheet name ?

Code:
wb.SaveAs ThisWorkbook.Path & "\" & ws.Range("A8").Value & "_" & ws.Name & ".xls"
 
Upvote 0
That change is PERFECT. Thank you so much, you just don't realize how much time you've saved me!
 
Upvote 0
Could I use this to insert today's date?

wb.SaveAs ThisWorkbook.Path & "\" & today() & "_" & ws.Name & ".xls"
 
Upvote 0

Forum statistics

Threads
1,222,688
Messages
6,167,644
Members
452,127
Latest member
jayneecm

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top