create new folder

kcaenj

Board Regular
Joined
Oct 13, 2004
Messages
197
What would the VBA code look like for seeing if a folder exists and if it doesn't then creating the new folder with that name.

Thanks,

KC
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

Von Pookie

MrExcel MVP
Joined
Feb 17, 2002
Messages
13,686
This works for me:

Code:
Sub test()
Dim myFolder As String

'the folder path you want to look for
myFolder = "C:\test\"

'if folder is not found, create folder
If Dir(myFolder, vbDirectory) = "" Then MkDir (myFolder)

End Sub
 

Forum statistics

Threads
1,136,579
Messages
5,676,652
Members
419,638
Latest member
GlenMc52

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
Top