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

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
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,223,227
Messages
6,170,847
Members
452,361
Latest member
d3ad3y3

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