PC Review
Forums
Newsgroups
Microsoft Excel
Microsoft Excel Programming
Macro to create folder
Forums
Newsgroups
Microsoft Excel
Microsoft Excel Programming
Macro to create folder
![]() |
Macro to create folder |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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 |
|
|
|
#2 |
|
Guest
Posts: n/a
|
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 |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

