Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Splitting worksheets into Files 1

Status
Not open for further replies.

scottie1

Programmer
Dec 12, 2003
50
GB
Mornin Everybody

Just a quick question, How do you split worksheets within a workbook all in one click of a macro and then save them as individual file's with the sheet name as the file names?

cheers

Adam
 
Basic way

Code:
sub Splitter()
dim stdPath as string
stdPath = "Base path for where you want to save the files\"
application.screenupdating = false
For each wks in thisworkbook.worksheets
    wks.copy
    activeworkbook.saveas stdPath & wks.name & ".xls"
    activeworkbook.close
next
end sub

Rgds, Geoff

Never test the depth of water with both feet

Help us to help you by reading FAQ222-2244 before you ask a question
 
Cheers Geoff

Thats spot on you
would think that would be a standard tool
 
Hi Xlbo

I don't suppose you know how what I need to do to the code to get it to run from any workbook.
 
Put it in your personal.xls and change THISworkbook to ACTIVEworkbook

It will then run on whatever is the active workbook at the time

Rgds, Geoff

Never test the depth of water with both feet

Help us to help you by reading FAQ222-2244 before you ask a question
 
Cheers Xlbo

I thought it was that part of the code. I am slowly learning.
 
THISworkbook will always refer to the workbook where the code is housed. It's very useful when you are opening and closing files all over the place and you need to refer to your main file

Rgds, Geoff

Never test the depth of water with both feet

Help us to help you by reading FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top