Create new named workbooks based on list

maartenfct

New Member
Joined
Jan 2, 2017
Messages
9
Hi All,

I'm trying to get a macro working to generate new (empty) workbooks named based on text entries in column A. Each cell in column A should correspond to a newly generated (and named) workbook. The newly generated workbooks should be in csv format.

Is there an easy way to do this? I've been wrestling with it for a while but can't seem to get it working..

Thanks!
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Try with this code:

Code:
Sub Create_new_workbooks()
    Dim i As Long, w As Object
    Dim wName As String, wPath As String
    
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    
    wPath = ThisWorkbook.Path & "\"
    '
    For i = 1 To Range("A" & Rows.Count).End(xlUp).Row
        wName = Cells(i, "A").Value
        Set w = Workbooks.Add
        w.SaveAs Filename:=wPath & wName & ".csv", FileFormat:=xlCSV, CreateBackup:=False
        w.Close False
    Next
    MsgBox "End"
End Sub
 
Upvote 0
Try with this code:

Code:
Sub Create_new_workbooks()
    Dim i As Long, w As Object
    Dim wName As String, wPath As String
    
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    
    wPath = ThisWorkbook.Path & "\"
    '
    For i = 1 To Range("A" & Rows.Count).End(xlUp).Row
        wName = Cells(i, "A").Value
        Set w = Workbooks.Add
        w.SaveAs Filename:=wPath & wName & ".csv", FileFormat:=xlCSV, CreateBackup:=False
        w.Close False
    Next
    MsgBox "End"
End Sub

Worked like a charm! Thanks a million!
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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