Hello All!
I have written the code below that does what I want it to do, but it is assigned to 1 ActiveX check box. I would like it to run anytime an ActiveX checkbox is used, but also only effect the one checkbox being activated. Any help or guidance is much appreciated!!! FYI there is over 1000 ActiveX checkboxes on this sheet, and none are linked to a cell for sorting and filtering purposes. Cheers!
Private Sub CheckBox1146_Click()
Set WS3 = Worksheets("Boilermakers")
Dim LRow As Long
Dim obeObj As Object
Application.ScreenUpdating = False
If WS3.Range("H2") = "" Then
For Each obeObj In ActiveSheet.OLEObjects
If TypeName(obeObj.Object) = "CheckBox" Then
If obeObj.Object.Value = True Then
obeObj.Object.Value = False
MsgBox "*** Add Job Number ***"
Range("H2").Select
End If
End If
Next
Application.ScreenUpdating = True
Exit Sub
Else
ThisWorkbook.Unprotect
WS3.Unprotect
For Each obeObj In ActiveSheet.OLEObjects
If TypeName(obeObj.Object) = "CheckBox" Then
If obeObj.Object.Value = True Then
If TypeName(obeObj.Object) = "CheckBox" Then
If obeObj.Object.Value = True Then
LRow = LRow + 1
If Cells(obeObj.TopLeftCell.Row, 47) = "" Then
Cells(obeObj.TopLeftCell.Row, 47).Value = Range("H2").Value
MsgBox "Employee Location Updated"
WS3.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True, AllowUsingPivotTables:=True
ActiveSheet.EnableSelection = xlUnlockedCells
ThisWorkbook.Protect
Else
MsgBox "Employee Already Assigned To A Job"
obeObj.Object.Value = False
WS3.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True, AllowUsingPivotTables:=True
ActiveSheet.EnableSelection = xlUnlockedCells
ThisWorkbook.Protect
End If
End If
Application.ScreenUpdating = True
Exit Sub
WS3.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True, AllowUsingPivotTables:=True
ActiveSheet.EnableSelection = xlUnlockedCells
ThisWorkbook.Protect
End If
End If
End If
Next
End If
Application.ScreenUpdating = True
End Sub
I have written the code below that does what I want it to do, but it is assigned to 1 ActiveX check box. I would like it to run anytime an ActiveX checkbox is used, but also only effect the one checkbox being activated. Any help or guidance is much appreciated!!! FYI there is over 1000 ActiveX checkboxes on this sheet, and none are linked to a cell for sorting and filtering purposes. Cheers!
Private Sub CheckBox1146_Click()
Set WS3 = Worksheets("Boilermakers")
Dim LRow As Long
Dim obeObj As Object
Application.ScreenUpdating = False
If WS3.Range("H2") = "" Then
For Each obeObj In ActiveSheet.OLEObjects
If TypeName(obeObj.Object) = "CheckBox" Then
If obeObj.Object.Value = True Then
obeObj.Object.Value = False
MsgBox "*** Add Job Number ***"
Range("H2").Select
End If
End If
Next
Application.ScreenUpdating = True
Exit Sub
Else
ThisWorkbook.Unprotect
WS3.Unprotect
For Each obeObj In ActiveSheet.OLEObjects
If TypeName(obeObj.Object) = "CheckBox" Then
If obeObj.Object.Value = True Then
If TypeName(obeObj.Object) = "CheckBox" Then
If obeObj.Object.Value = True Then
LRow = LRow + 1
If Cells(obeObj.TopLeftCell.Row, 47) = "" Then
Cells(obeObj.TopLeftCell.Row, 47).Value = Range("H2").Value
MsgBox "Employee Location Updated"
WS3.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True, AllowUsingPivotTables:=True
ActiveSheet.EnableSelection = xlUnlockedCells
ThisWorkbook.Protect
Else
MsgBox "Employee Already Assigned To A Job"
obeObj.Object.Value = False
WS3.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True, AllowUsingPivotTables:=True
ActiveSheet.EnableSelection = xlUnlockedCells
ThisWorkbook.Protect
End If
End If
Application.ScreenUpdating = True
Exit Sub
WS3.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True, AllowUsingPivotTables:=True
ActiveSheet.EnableSelection = xlUnlockedCells
ThisWorkbook.Protect
End If
End If
End If
Next
End If
Application.ScreenUpdating = True
End Sub