Run these two macros only when the respective checkbox is checked

dhavalpaun

New Member
Joined
Mar 30, 2016
Messages
12
[FONT=&quot]Hello[/FONT]
[FONT=&quot]I have two macros (in "this workbook" object in VBA)for which I want to have two checkboxes in a worksheet (each for one macro)[/FONT]
[FONT=&quot]And I wanna to run these macro if their respective checkbox is selected in a worksheet.[/FONT]
[FONT=&quot]Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

ThisWorkbook.Save

End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim sFileName As String
Dim sDateTime As String


With ThisWorkbook
sDateTime = " (" & VBA.Format(Now, "yyyy-mm-dd hhmm") & ").xlsm"
sFileName = Replace(.Name, ".xlsm", sDateTime)
.SaveCopyAs VBA.Environ$("UserProfile") & "\My Documents" & sFileName
End With

End Sub[/FONT]

[FONT=&quot]Thank you in advance for your answers.[/FONT]
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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