I have this code:
Private Sub OptionButton1_Click()
If OptionButton1.Value = True Then
Application.EnableEvents = False
Application.DisplayAlerts = False
ActiveSheet.Unprotect ("ALS rules!")
With ActiveWorkbook.ActiveSheet.Range("A18:A1269").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="1,2,3"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = "Options"
.ErrorTitle = ""
.InputMessage = "Choose from list:"
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
[B16] = "Master function"
[I16] = "Related component"
Application.EnableEvents = True
Application.DisplayAlerts = True
ActiveSheet.Protect AllowSorting:=True, AllowFiltering:=True, _
AllowUsingPivotTables:=True, DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="ALS rules!"
End If
End Sub
But I get the error message: The object invoked has disconnected from its clients. And it seam to be this line which is the problem:
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="1,2,3"
Does anyone have an idea of what could be the problem?
/ David