Create subfolders in a folder

M

Myrna Rodriguez

Hello VB Bugs!

I was successful in creating a folder based on an excel
cell. The folder is named accordingly what the user types.
This is the following code I use to create first folder.
How can I create subfolders and label them permanently??
The 1st folder name will always be relative and subfolders name will be
absolute.
Thanks & enjoy the live bugs!! Myrna

Dim x As String
Dim cell As Range

On Error Resume Next
cLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For Each cell In Range("A" & cLastRow)
x = "S:\Order Folders\2004 Open Orders\" & cell.Value
MkDir x
Next cell

Note: This procedure is excuted in a UserForm OK Button


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
K

Kelly n español

Dear Myrna

Assuming that everything you included is already working for you, the
I would just add two lines (well, two lines for each subfolder you wis
to make)

look at the following:


Dim x As String
Dim cell As Range

On Error Resume Next
cLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For Each cell In Range("A" & cLastRow)

x = "S:\Order Folders\2004 Open Orders\" & cell.Value

y = "S:\Order Folders\2004 Open Orders\" & cell.Value & "\Other folde
Y"

MkDir x

MkDir y


Next cell



...do you think that would do it for you?

(note: i did not change or delete any of your code, I only inserted on
line after your "x= " line and one more line after your "MkDir x" line
That is all)

One issue to watch out for is that when you use MkDir, you can ge
errors if you want to create "C:\Here\There" if you have not FIRS
created "C:\Here"

But, assuming that your code didn't have any problem creating "S:\Orde
Folders\2004 Open Orders\" & cell.Value -- then you shouldn't have
problem creating "S:\Order Folders\2004 Open Orders\" & cell.Value
"\Other folder Y" as a next step.

Does that make sense?

Let me know if there's a problem, I will keep an eye on this thread.

-Kelly
_______________________________
http://kellyjones.netfirms.co
 
M

Myrna Rodriguez

Hi Kelly...

Thanks a million bugs!!! The code you shared is magic...
I was also able to create additional subfolders within each subfolder.
enjoy life!! myrna


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top