How to create folders in Windows Explorer using names in col A?

MikeL

Active Member
Joined
Mar 17, 2002
Messages
488
Office Version
  1. 365
Platform
  1. Windows
Is it possible to use a loop thru a list of names in col A of a worksheet and create new folders in Windows Explorer with these names?

If in Col A was a list of states:
Delaware
California
Alaska

can a macro be run to create folders in C:\Test with these state names?

Thanks,
Mike
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
try
Code:
Sub test()
Dim fso As Object, mySir As String, temp As String
Set fso = CreateObject("Scripting.FileSystemObject")
myDir = "c:\test\"
On Error Resume Next
For Each r In Range("a1", Range("a" & Rows.Count).End(xlUp))
    Err.Clear
    temp = fso.CreateFolder(myDir & r.Value)
    If Err = 0 Then
        MsgBox temp & vbLf & " was created.", vbInformation
    Else
        MsgBox Err.Description
    End If
Next
Set fso = Nothing
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,671
Messages
6,132,041
Members
449,697
Latest member
bororob85

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