Advice on VBA Code

VBA learner ITG

Active Member
Joined
Apr 18, 2017
Messages
267
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I was wondering if i can get your expertise!

Is there a code that anyone knows of that will do the following:

1. Split a workbook tabs into new separate workbooks.
2. Save each new workbook created as the original file name including with the tab name that has been moved into the new workbook
3.Create a folder for these new saved workbook.

Any help would be appreciated.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Is there a code that anyone knows of that will do the following:
Code must be constucted to meet the specifications of the designer. There are some, so called, generic codes written. But they usually require some degree of modification for practical use by a specific user. Here is a basic code to do what you describe. The code will use "C:\Temp" as the directory path for the new files. You can change that in the code to meet your needs.
Code:
Sub makeNewWBs()
Dim twb As Workbook, wb As Workbook, sh As Worksheet, fPath As String
Set twb = ThisWorkbook
fPath = "C:\Temp\"
    For Each sh In twb.Sheets
        sh.Copy
        Set wb = ActiveWorkbook
        wb.SaveAs fPath & twb.Name & "_" & sh.Name & ".xlsx" 'Assumes xl version 2007+ FileFormat:=51
        wb.Close False
    Next
End Sub

This code does not compensate for any sheets which contained formulas with external references. If there are any of those formulas in the sheets, the cells will appear with error flags.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,950
Messages
6,122,428
Members
449,083
Latest member
Ava19

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