VBA workbook saveas to documents example please

tynawg

New Member
Joined
Oct 11, 2019
Messages
42
Hi,
Breaking the problem into small parts. I want to use VBA to save an copy of a workbook to a specific locations, documents on C drive as an example. The file name will be taken from the data in cells A1 and A2 for identification.
So first, save the file named from cell/s data. Then save as to documents.
I will post the next step as a separate question once this part is solved.
Any help much appreciated.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
For example:

VBA Code:
Sub test()
  Dim sPath As String, sName As String
  sPath = "C:\books\"
  sName = Range("A1") & Range("A2")
  ActiveWorkbook.SaveCopyAs sPath & sName
End Sub

What do you mean with:
"Then save as to documents. "
 
Upvote 0
For example:

VBA Code:
Sub test()
  Dim sPath As String, sName As String
  sPath = "C:\books\"
  sName = Range("A1") & Range("A2")
  ActiveWorkbook.SaveCopyAs sPath & sName
End Sub

What do you mean with:
"Then save as to documents. "

Hello and thank you for your time and help.
I suspect what I mean is where I want the new file saved to, i.e. save to documents, or desktop etc? I think you have it at sPath = "C:\books\" so perhaps It changes from books to documents?
Regards,
Wayne
 
Upvote 0
Just change that line to the name of the folder where you want to save the files.
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

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