Hi there,
I made a vba code with double click function
i wonder if there is a cleanup necessary for make it go faster?
Private Sub Worksheet_BeforeDoubleClick(ByVal target As range, Cancel As Boolean)
Dim varResponse As Variant
Application.ScreenUpdating = False
If InRange(ActiveCell, range("F11:I20,F26:I35,F41:I50")) Then
ActiveSheet.Unprotect
If ActiveCell.Locked = True Then
If ActiveCell.Value = NullString Then varResponse = MsgBox("Wilt u de score veranderen?", vbYesNo, "Scores Wissen?")
If varResponse <> vbYes Then Exit Sub
If ActiveCell.Column = 6 Then GoTo Colom1:
If ActiveCell.Column = 7 Then GoTo Colom2:
If ActiveCell.Column = 8 Then GoTo Colom3:
If ActiveCell.Column = 9 Then GoTo Colom4:
Else
If ActiveCell.Column = 6 Then GoTo Colom1:
If ActiveCell.Column = 7 Then GoTo Colom2:
If ActiveCell.Column = 8 Then GoTo Colom3:
If ActiveCell.Column = 9 Then GoTo Colom4:
Exit Sub
End If
Else
If InRange(ActiveCell, range("S11:V20,S26:V35,S41:V50")) Then
ActiveSheet.Unprotect
If ActiveCell.Locked = True Then
If ActiveCell.Value = NullString Then varResponse = MsgBox("Wilt u de score veranderen?", vbYesNo, "Scores Wissen?")
If varResponse <> vbYes Then Exit Sub
If ActiveCell.Column = 19 Then GoTo Colom1:
If ActiveCell.Column = 20 Then GoTo Colom2:
If ActiveCell.Column = 21 Then GoTo Colom3:
If ActiveCell.Column = 22 Then GoTo Colom4:
Else
If ActiveCell.Column = 19 Then GoTo Colom1:
If ActiveCell.Column = 20 Then GoTo Colom2:
If ActiveCell.Column = 21 Then GoTo Colom3:
If ActiveCell.Column = 22 Then GoTo Colom4:
Exit Sub
End If
Else
If InRange(ActiveCell, range("AF11:AI20,AF26:AI35")) Then
ActiveSheet.Unprotect
If ActiveCell.Locked = True Then
If ActiveCell.Value = NullString Then varResponse = MsgBox("Wilt u de score veranderen?", vbYesNo, "Scores Wissen?")
If varResponse <> vbYes Then Exit Sub
If ActiveCell.Column = 32 Then GoTo Colom1:
If ActiveCell.Column = 33 Then GoTo Colom2:
If ActiveCell.Column = 34 Then GoTo Colom3:
If ActiveCell.Column = 35 Then GoTo Colom4:
Else
If ActiveCell.Column = 32 Then GoTo Colom1:
If ActiveCell.Column = 33 Then GoTo Colom2:
If ActiveCell.Column = 34 Then GoTo Colom3:
If ActiveCell.Column = 35 Then GoTo Colom4:
Exit Sub
End If
Else
If InRange(ActiveCell, range("AS11:AV20,AS26:AV35")) Then
ActiveSheet.Unprotect
If ActiveCell.Locked = True Then
If ActiveCell.Value = NullString Then varResponse = MsgBox("Wilt u de score veranderen?", vbYesNo, "Scores Wissen?")
If varResponse <> vbYes Then Exit Sub
If ActiveCell.Column = 45 Then GoTo Colom1:
If ActiveCell.Column = 46 Then GoTo Colom2:
If ActiveCell.Column = 47 Then GoTo Colom3:
If ActiveCell.Column = 48 Then GoTo Colom4:
Else
If ActiveCell.Column = 45 Then GoTo Colom1:
If ActiveCell.Column = 46 Then GoTo Colom2:
If ActiveCell.Column = 47 Then GoTo Colom3:
If ActiveCell.Column = 48 Then GoTo Colom4:
Exit Sub
Colom1:
ActiveCell.Value = "X"
ActiveCell.Locked = True
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = NullString
ActiveCell.Locked = True
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = NullString
ActiveCell.Locked = True
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = NullString
ActiveCell.Locked = True
ActiveCell.Offset(1, 0).Select
ActiveSheet.Protect
Exit Sub
Colom2:
ActiveCell.Value = "X"
ActiveCell.Locked = True
ActiveCell.Offset(0, -1).Select
ActiveCell.Value = NullString
ActiveCell.Locked = True
ActiveCell.Offset(0, 2).Select
ActiveCell.Value = NullString
ActiveCell.Locked = True
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = NullString
ActiveCell.Locked = True
ActiveCell.Offset(1, 0).Select
ActiveSheet.Protect
Exit Sub
Colom3:
ActiveCell.Value = "X"
ActiveCell.Locked = True
ActiveCell.Offset(0, -2).Select
ActiveCell.Value = NullString
ActiveCell.Locked = True
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = NullString
ActiveCell.Locked = True
ActiveCell.Offset(0, 2).Select
ActiveCell.Value = NullString
ActiveCell.Locked = True
ActiveCell.Offset(1, 0).Select
ActiveSheet.Protect
Exit Sub
Colom4:
ActiveCell.Value = "X"
ActiveCell.Locked = True
ActiveCell.Offset(0, -3).Select
ActiveCell.Value = NullString
ActiveCell.Locked = True
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = NullString
ActiveCell.Locked = True
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = NullString
ActiveCell.Locked = True
ActiveCell.Offset(1, 0).Select
ActiveSheet.Protect
End If
Exit Sub
End If
End If
End If
End If
ActiveCell.Offset(1, 0).Select
Application.ScreenUpdating = True
End Sub
Bookmarks