PC Review Forums Newsgroups Microsoft Excel Microsoft Excel Programming Macro to create folder

Reply

Macro to create folder

 
Thread Tools Rate Thread
Old 20-10-2003, 05:40 PM   #1
yo beee
Guest
 
Posts: n/a
Default Macro to create folder


Hi all,
I am trying to get a macro to save my workbook. I need the macro to name
the workbook from whatever is in cell A1 and have it create a folder on the
hard drive with the same name and save the workbook in that folder. The
folder will reside in My Documents.
So, if the cell A1 is called "20456", I need the name of the newly
created folder to be 20456 and the name of the workbook saved in the "20456"
folder to be "20456.xls".
Any help would be greatly appreciated.
TIA,

Yobeee


  Reply With Quote
Old 21-10-2003, 02:10 AM   #2
Dave Peterson
Guest
 
Posts: n/a
Default Re: Macro to create folder

Something like:

Option Explicit
Sub testme1()

Const myFolder As String = "C:\my documents\"

With Worksheets("sheet1").Range("a1")
On Error Resume Next
MkDir myFolder & .Value
On Error GoTo 0
ThisWorkbook.SaveAs Filename:=myFolder & .Value & "\" & .Value & ".xls"
End With


End Sub


yo beee wrote:
>
> Hi all,
> I am trying to get a macro to save my workbook. I need the macro to name
> the workbook from whatever is in cell A1 and have it create a folder on the
> hard drive with the same name and save the workbook in that folder. The
> folder will reside in My Documents.
> So, if the cell A1 is called "20456", I need the name of the newly
> created folder to be 20456 and the name of the workbook saved in the "20456"
> folder to be "20456.xls".
> Any help would be greatly appreciated.
> TIA,
>
> Yobeee


--

Dave Peterson
ec35720@msn.com
  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off