VBS script to save Tabs as separate Excel xlsx files

I have a large sheet and I have a tab called dashboard and would like to save the whole tab in another file. Keep in mind this tab has many links. Does anyone have a quick VBScript to save this file?
LVL 19
Edward PamiasTeam Lead RRS DeskAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

regmigrantCommented:
The basic principle is simple and described here:
http://www.extendoffice.com/documents/excel/628-excel-split-workbook.html#vba

If there are links between the sheets and you want those to become external references then it will need some fettling
0
Edward PamiasTeam Lead RRS DeskAuthor Commented:
I tried that and it did not work for me. I got an error when running it.
0
regmigrantCommented:
the code in there is fairly straight forward but I'll need some help to find out what went wrong:

What error did you get?
When did it happen?

Can you post a sample of the workbook?

I created the attached by following the steps outlined at the link. Copy this into an empty folder and then run the macro from the developer tab and see if it works
NB - it will cause problems if one of the tabs has the same name as the workbook because the new file will attempt to overwrite the old
Book1.xlsm
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Edward PamiasTeam Lead RRS DeskAuthor Commented:
it stopped at WS.copy after it saved most of the tabs.
0
Edward PamiasTeam Lead RRS DeskAuthor Commented:
I really only need to save one tab, named DASHBOARD.
0
[ fanpages ]IT Services ConsultantCommented:
regmigrant: In case this is the root of the issue...

epamias has asked for a solution using VBScript, & the link you posted to ExtendOffice.com points to Visual Basic for Applications code:

Sub Splitbook()
'Updateby20140612
Dim xPath As String
xPath = Application.ActiveWorkbook.Path
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each xWs In ThisWorkbook.Sheets
    xWs.Copy
    Application.ActiveWorkbook.SaveAs Filename:=xPath & "\" & xWs.Name & ".xls"
    Application.ActiveWorkbook.Close False
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

Open in new window


epamias:

Are you wishing to run code from within MS-Excel, or using a VBScript file?
0
regmigrantCommented:
Thanks Fanpages, it was late, I was tired :)

@epimias

if the VBA approach is acceptable then one way is to add  an If statement to only work with DASHBOARD:-

Sub Splitbook()
'Updateby20140612
Dim xPath As String
xPath = Application.ActiveWorkbook.Path
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each xWs In ThisWorkbook.Sheets
 if xWs.name = "DASHBOARD" then 
       xWs.Copy
       Application.ActiveWorkbook.SaveAs Filename:=xPath & "\" & xWs.Name & ".xls"
       Application.ActiveWorkbook.Close False
endif
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

Open in new window


There is an obvious quicker way without the loop but I don't have time at the moment, Fanpages?
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Martin LissOlder than dirtCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.