MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Macro to create variable folder names


Posted by Matt on February 14, 2002 3:10 AM

Firstly, I need to save a file and use a cell reference as part of the file name, e.g. report "w/c 1/1/1". Any ideas?

Secondly, I need to create a new folder also using a cell reference? Is this possible too?

thanks

Matt


Posted by DK on February 14, 2002 3:45 AM

Use something like this to save the file:-

ActiveWorkbook.SaveAs "C:\temp\file" & Range("A1") & ".xls"

To create a folder use MkDir e.g.

MkDir "C:\temp\" & Range("A1")

HTH,
D

Posted by Matt on February 14, 2002 4:07 AM

DK

Thanks that's great, just have one slight problem now, I'm trying to save the file to the directory that I just created. Is it possible to save the file to the variable directory name with a variable file name as I can't seem to get it to work

Thanks again

Matt

Posted by DK on February 14, 2002 6:53 AM

As long as you're creating the folder first and then saving the file, it should work. If not, it's probably an idea to post your code.

D

Posted by Matt on February 15, 2002 2:07 AM

Thanks Now all working