Create multiple folder at different location based on Cells

Max02

New Member
Joined
Apr 10, 2022
Messages
2
Office Version
  1. 2016
Hello,

Need help!!

I need to create multiple folders based on the names in cells. All the folder name will be in column A
and the location or path where the folder needs to be created Column B. I was trying for codes based in forum but cannot do for different location.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Welcome to the Board!

If your data look something like this:
1649679613597.png


Then code like this would work:
VBA Code:
Sub MakeFolders()

    Dim lr As Long
    Dim r As Long
    Dim fName As String
    
'   Find last row in column A with data
    lr = Cells(Rows.Count, "A").End(xlUp).Row
    
'   Loop through all rows starting with row 2
    For r = 2 To lr
'       Build folder name
        If Right(Cells(r, "B"), 1) = "\" Then
            fName = Cells(r, "B") & Cells(r, "A")
        Else
            fName = Cells(r, "B") & "\" & Cells(r, "A")
        End If
'       Make folder
        MkDir fName
    Next r
        
    MsgBox "Macro complete!"
    
End Sub
 
Upvote 0
Solution
You are welcome.
Glad I was able to help!
 
Upvote 0

Forum statistics

Threads
1,215,493
Messages
6,125,128
Members
449,206
Latest member
burgsrus

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