Sunday, November 24, 2013

Creation folder path using macro

Hi fellows

This is another vba which you can find similar coding through googles. Below is how I do it from excel.

1.  Let's say you want to create many folders in this folder below in C:\dummy\

e.g. folder a, folder b, folder c.

2.  In your excel key in the following as shown below:


In cell B2 type: C:\dummy

In cell E1 onwards, type
a, b, c

3. this vba only works 3 times. You can change the number of times by changing the numbers under for loop

Sub test()

Dim abcfolder As String
Dim path As String



path = Cells(2, 2).Value

On Error Resume Next
MkDir path
On Error GoTo 0





For i = 1 To 3

abcfolder = Cells(i, 5).Value



MkDir path & "\" & abcfolder

Next i

End Sub

4. Then the folders are created.

No comments:

Post a Comment