Thread: Folder Creation
View Single Post
 
Old 05-16-2022, 02:10 AM
ranjan ranjan is offline Windows 10 Office 2019
Advanced Beginner
 
Join Date: May 2021
Posts: 77
ranjan is on a distinguished road
Default Folder Creation

I want to create a folders based on a excel value.

Folder creation path should be as a browse option.

strPath = InputBox("Enter Files Path") & ""

I had a below code, can anyone modified as per my requirement.

It is creating a folders where a macro excel sheet is exists but i need to change as "choose a folder from a browse option to where i want to create a folders" because every time need to change a location and it is more dynamic.

Please review the below code, your help is highly appreciated.



Code:
Sub MakeFolders()
Dim Rng As Range
Dim maxRows, maxCols, r, c As Integer
Set Rng = Selection
maxRows = Rng.Rows.Count
maxCols = Rng.Columns.Count
For c = 1 To maxCols
r = 1
Do While r <= maxRows
If Len(Dir(ActiveWorkbook.Path & "\" & Rng(r, c), vbDirectory)) = 0 Then
MkDir (ActiveWorkbook.Path & "\" & Rng(r, c))
On Error Resume Next
End If
r = r + 1
Loop
Next c
End Sub
Reply With Quote