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

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

Forum statistics

Threads
1,218,054
Messages
6,140,176
Members
450,266
Latest member
LostInSwiss

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