I have the following sheet code which is doing what I want it to do but I only want it to execute if I click commandbutton1. How do I do that?
Code:
Private Sub CommandButton1_Click()
'
End Sub
---------------------------------------------------
Private Sub CommandButton2_Click()
'
End Sub
-------------------------------------------------
Private Sub ToggleButton1_Click()
End Sub
-------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub
-------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
' "Other event code"
++++++++
' Modify ROW ON DATA ENTRY TAB
Dim rng1 As Range
Dim cell As Long
If Not Intersect(Target, Range("d14:L5013")) Is Nothing Then
On Error GoTo Oops
If ActiveCell.row = Target.row Then
MsgBox "same row"
Application.EnableEvents = False
ActiveSheet.Unprotect Password:="timewarp"
With Range("d" & Target.row & ":M" & Target.row)
.Cells.Locked = False
Target.Font.Color = 500
End With
Else
Range("d" & Target.row & ":M" & Target.row).Cells.Locked = True
Target.Font.Color = 500
MsgBox "row changed"
End If
Range("a20").Select
Else
MsgBox "not intersect"
End If
'
outtahere:
Application.EnableEvents = True
ActiveSheet.Protect Password:="timewarp"
MsgBox "exit"
Exit Sub
Oops:
MsgBox "Error"
Resume outtahere
+++++++++++++++
' "More event code here"
End Sub