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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top