Combine 2 VBA Script's to 1 Command Button

VinceF

Board Regular
Joined
Sep 22, 2007
Messages
199
Office Version
  1. 2016
Platform
  1. Windows
Greetings,
Hopefully a simple fix.
Is it possible to combine 2 scripts to 1 command button, if so your assistance would be very much appreciated.
Script 1 saves the workbook with the value on the MAIN sheet, in cell AA3
Script 2 adds "1" to the value in cell AA3 when saving and closing the workbook

Script 1
Sub SaveWithTodaysDate()
ActiveWorkbook.SaveAs ("C:\Golf\Indianwood Quota - Skins\Results\" & ThisWorkbook.Sheets("Main").Range("AA3").Value & ".xlsm")
End Sub

Script 2
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Range("AA3") = Range("AA3") + 1
End Sub

Thank You,
VinceF
Excel 2016
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
You could try something like:

VBA Code:
Sub SaveWithTodaysDate()
Range("AA3") = Range("AA3") + 1
ActiveWorkbook.SaveAs ("C:\Golf\Indianwood Quota - Skins\Results\" & ThisWorkbook.Sheets("Main").Range("AA3").Value & ".xlsm")
End Sub
 
Upvote 0
Solution
Candyman,
Thank you...It was adding 1 to cell AA3 then saving it so I switched the order in the script to save it first then add 1 to cell AA3 and it's working perfectly.
I very much appreciate your expertise....!
Another problem solved by the experts...

Thanks,
VinceF
 
Upvote 0

Forum statistics

Threads
1,224,763
Messages
6,180,823
Members
452,997
Latest member
gimamabe71

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