Copy worksheet into new [macro enabled] workbooks based on cell values

kayfish

New Member
Joined
Dec 10, 2015
Messages
1
Hello: I have a macro enabled worksheet that I would like to essentially "save as" multiple workbooks, with each file name based on a list of cell values. My file names are listed in column A of sheet 1, while my second worksheet (titled "Template") is what I would like to duplicate and "save as" multiple times based on my list of file names on sheet 1. I found a code (pasted below) that can copy my "Template" worksheet multiple times based on my list, but I would like to instead save them as separate macro-enabled files (e.g. workbooks) instead of separate worksheets in the same workbook. I've tried several codes and none seem to work. I am also open to using the code below to create the separate sheets, and then using a second code to extract those sheets into separate workbooks...either one will work. I am using Excel 2013 (Windows 7). Thank you!


Sub AddSheet()

Application.ScreenUpdating = False
Dim bottomA As Integer
bottomA = Range("A" & Rows.Count).End(xlUp).Row
Dim c As Range
Dim ws As Worksheet

For Each c In Range("A1:A" & bottomA)
Set ws = Nothing
On Error Resume Next
Set ws = Worksheets(c.Value)
On Error GoTo 0
If ws Is Nothing Then
Sheets("Template").Select
Sheets("Template").Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = c.Value
End If
Next c
Application.ScreenUpdating = True
End Sub
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Forum statistics

Threads
1,216,380
Messages
6,130,274
Members
449,570
Latest member
TomMacca52

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