SaveCopyAs with new filename from two cells

jarzack

New Member
Joined
Jun 14, 2024
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I'm still new to learning VBA.

I have a SharePoint that will hold an Excel template. I want to force a user to use SaveCopyAs instead of Save As. I would like for the new filename to come from cells J3, J9 and have a - as a separator. Any suggestions?

Thanks in advance!
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hmm. Theoretically user can always SaveAs if he wants. Until you do not block it in some way (VBA doable but on sharepoint? I am too familiar with scripts).
Saving with new filename from based on cells values is not a problem:

Something like:

VBA Code:
Sub SlaintheMhath()

Dim FPath As String, FName As String

    FPath = "C:\Users\UserName\MyFolderSynchronisedWithShareDrive\"    ' User has to have synchronised folder with sharepoint folder

    FName = Range("J3").Value & " " & Range("J9").Value & ".xlsm"

    Application.DisplayAlerts = False

    ActiveWorkbook.SaveCopyAs Filename:=FPath & FName

    Application.DisplayAlerts = True

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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