VBA to sve a file new f

gladfan

New Member
Joined
Aug 10, 2006
Messages
12
I am after a little help please, need to build a macro to save a file to a new folder.

So the bas path is already there say C:\files

and I have a way to save the file into the same name as cell b7

but what I want is to create a folder for it of the same name so the b7 would be the folder \b7 and the file also b7.xls

c:\files\b7\b7.xls

I can do the file name but for some reason I cant make excel write the new folder based on the cell name.

Help please!
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Add this code to your code module. If the folder doesn't exist it will create it and save the file to that folder.

Dim FName As String

On Error Resume Next

FName = Cells(7, 2).Value
On Error Resume Next
MkDir "C:\Files" & FName
ActiveWorkbook.SaveAs FileName:="C:\Files" & FName & "" & FName & ".xlsm", FileFormat:=52
End Sub
 
Upvote 0

Forum statistics

Threads
1,225,743
Messages
6,186,778
Members
453,371
Latest member
HMX180

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top