I'm looking to create folders on the fly with the folderpaths being based on defined variables.
Could someone please have a look at my code below and tell me where Im going wrong?
![]()
Please Login or Register to view this content.
I'm looking to create folders on the fly with the folderpaths being based on defined variables.
Could someone please have a look at my code below and tell me where Im going wrong?
![]()
Please Login or Register to view this content.
Last edited by TonyforVBA; 10-24-2011 at 06:19 AM.
I got frustrated long ago with making folders, so I wrote a routine to handle it for me in all my macros.
Make Folders and Subfolders
Use the UDF version of that function, put it in the same module, then you can call it like so:
It will make every folder and subfolder in that path if necessary.![]()
Please Login or Register to view this content.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
?None of us is as good as all of us? - Ray Kroc
?Actually, I *am* a rocket scientist.? - JB (little ones count!)
To be truly "international I would use Application.PathSeparator instead of "\"
Hope that helps.
RoyUK
--------
For Excel Tips & Solutions, free examples and tutorials why not check out my web site
Free DataBaseForm example
Thanks, Roy, awesomely correct. I've updated to use that from now on.
Hi guys,
Cheers for the feedback. However Im still not entirely sure on how to go about using this code.
I do not have a list containg all the directories. Rather I wish to use cell referances set as variables to create folders within the directory.
I'Ve included a snapshot of my code (including the given MakeDirectories Sub). Could you offer any advice?
![]()
Please Login or Register to view this content.
In post #2 I gave a "suggestion" on how you would call this macro based on your original macro.
The MakeDirectories takes ONE parameter. It analyzes on long string and makes sure every folder exists, from the root directory all the way down to the final folder. The string should not include a file name, folders only.
So, based on your original macro I made a guess at how to construct that one long path string and gave that example in post #2.
So edit your macro to only pass one string. Your comma creates two string parameters, and only one is accepted. Give it another shot.
BTW, do not edit the UDF itself the way you did, you made it unworkable. Go back to the original macro. The UDF version is further down on the sheet, you took the wrong version.
Use the UDF version of that function, put it in the same module, then you can call it like so:
It will make every folder and subfolder in that path if necessary.![]()
Please Login or Register to view this content.
Last edited by JBeaucaire; 10-20-2011 at 10:55 AM.
Thats worked perfectly for me. Thanks for your help. A very usefull piece of code.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks