Macro to create folder

  • Thread starter Thread starter yo beee
  • Start date Start date
Y

yo beee

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
 
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
 
Back
Top