Need Help saving workbook with VBA (specific filename)

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
785
Office Version
  1. 365
Platform
  1. Windows
Hi,
Sorry if this is not much to go on but im wanting to save workbook by vba to a set directory (directory in cell)

Example (Sheet1):
A1 = c:\temp\reports\

B1 = 24-03-2017

I would like it saved in the above directory with filename:
Report_24-03-2017.xlsm

Also is it possible, to clear 2 worksheets of the new file? To get its size low as possible

Is all this possible from a macro?

Thanks for any help
 

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.
Try:
Code:
Workbooks.SaveAs Range("A1").Value & "Report_" & Range("B1").Value) & ".xlsm"
 
Upvote 0
Code:
Sub Save()
Dim s1 As String
Dim s2 As String
s1 = Cells(1, 1).Text
s2 = Cells(1, 2).Text
ActiveWorkbook.SaveAs Filename:="" & s1 & "Report_" & s2, FileFormat:=53, CreateBackup:=False
Sheets("nameofyoursheet").Delete
Sheets("nameofyoursheet").Delete

End Sub
 
Upvote 0
Thanks for the replies, both look good.

I forgot to mention that i dont want any sheets of the current workbook cleared, only the ones of the new workbook. Not sure if the above does this but ill try it out.
 
Upvote 0
Code:
Sub Save()
Dim s1 As String
Dim s2 As String
s1 = Cells(1, 1).Text
s2 = Cells(1, 2).Text
ActiveWorkbook.SaveAs Filename:="" & s1 & "Report_" & s2, FileFormat:=53, CreateBackup:=False
Sheets("nameofyoursheet").Delete
Sheets("nameofyoursheet").Delete

End Sub

hi,this saves ok but after running the macro - the saved workbook is open
if possible i would like the original workbook to stay open as it was before running macro
 
Upvote 0
Still need help with this please

Basically just need to save into the directory but keep the existing workbook open.

All scripts ive tried "save as" then the new file is open
 
Upvote 0

Forum statistics

Threads
1,214,520
Messages
6,120,016
Members
448,936
Latest member
almerpogi

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