dhavalpaun
New Member
- Joined
- Mar 30, 2016
- Messages
- 12
[FONT="]Hello[/FONT]
[FONT="]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="]And I wanna to run these macro if their respective checkbox is selected in a worksheet.[/FONT]
[FONT="]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="]Thank you in advance for your answers.[/FONT]
[FONT="]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="]And I wanna to run these macro if their respective checkbox is selected in a worksheet.[/FONT]
[FONT="]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="]Thank you in advance for your answers.[/FONT]