Excel VB code to achieve typing foldernames

pix_jnr

New Member
Joined
Oct 12, 2005
Messages
13
hey guys!

just want to write a macro in excel which will achieve the following

- I have spreadsheet containing data
- In Column A is a list of names
- i want to run a macro that will create a new folder (on my hard drive) for each name in column A with the folder name being the name of that cell. Then save the same spreadsheet in this new folder.
-Repeat this for all the names in col A. (ie:my hard drive will contain X new folders that have the names of the data in col A)

Make sense? i dont think excel is allowed to do this or cant do this? ne help would be grealy appreciated! (save me so much time!!!)

Thanks to all! :cool:
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Like this :
Code:
Sub test()
    Dim MyFolder As String
    Dim Myrow As Long
    Dim RootFolder As String
    '--------------------------------------
    RootFolder = "C:\TEMP\"
    ChDrive RootFolder
    Myrow = 1
    While ActiveSheet.Cells(Myrow, 1).Value <> ""
        MyFolder = RootFolder & ActiveSheet.Cells(Myrow, 1).Value
        MkDir MyFolder
        Myrow = Myrow + 1
    Wend
    MsgBox ("Done")
End Sub
 
Upvote 0
Thanks for that! worked a treat! i hadnt heard of Mkdir - which is sort of the key to the problem. thanks for your help!
 
Upvote 0

Forum statistics

Threads
1,214,946
Messages
6,122,401
Members
449,081
Latest member
JAMES KECULAH

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