Creating Sub Folders using VBA

breitnet

New Member
Joined
Jan 18, 2018
Messages
13
Hello All, I am looking for some help creating sub folders in a VBA Macro. I have code the allows me to browse where to create a folder using the cell value as the name. What I would like to do is create another sub folder under the previously selected folder, named from a new cell value.

'Sub Create_Folders()

penAt = "My computer:"

Set ShellApp = CreateObject("Shell.Application").BrowseForFolder(0, "Please Choose The Folder For This Project", 0, OpenAt)

'Set the folder to that selected. (On error in case cancelled)
On Error Resume Next
BrowseForFolder = ShellApp.Self.Path

'new folder location
Dim Rng As Range
Set Rng = Sheet1.Cells(100, 8).Value

'create folder in selected directory
If Sheet1.Cells(100, 8).Value <> "" Then
MkDir (BrowseForFolder & "" & Sheet1.Cells(100, 8).Value)
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,277
Messages
6,171,149
Members
452,382
Latest member
RonChand

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