• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Create a New Excel file a New Folder in the Specified Location

Hi i am trying to VBA

I have file name range A2:A9, i want create a new excel file ( for 8 persons new excel files) in the specified location (C:\Users\k.sivaprakasam\Desktop\New folder)

Pls help me
 

Attachments

AlanSidman

Well-Known Member
Code:
Option Explicit

Sub NewFile()
    Dim i As Long, lr As Long, path As String
    Dim wb As Workbook
    path = Range("B2")
    lr = Range("A" & Rows.Count).End(xlUp).Row
    For i = 2 To lr
        Set wb = Workbooks.Add
        wb.SaveAs path & "\" & Range("A" & i) & ".xlsm"
    Next i

End Sub
 

Marc L

Excel Ninja
  • ´New folder' already exists ? If not : to run on which Excel version(s) ?

  • Which kind of workbooks to create : classic .xlsx, binary .xlsb, … ?
 
Now, I'm using the Excel version is 2013 and workbooks is to be create .xlsx

And also

I have some one VBA module program code, can i apply to all excel version???
 

Marc L

Excel Ninja
It may depend on the answer of the first point of my previous post : « 'New folder' already exists ? »​
 
Code:
Option Explicit

Sub NewFile()
    Dim i As Long, lr As Long, path As String
    Dim wb As Workbook
    path = Range("B2")
    lr = Range("A" & Rows.Count).End(xlUp).Row
    For i = 2 To lr
        Set wb = Workbooks.Add
        wb.SaveAs path & "\" & Range("A" & i) & ".xlsm"
    Next i

End Sub
Hi,

Kindly rectify the error

63729
 
Top