Aug 16 2022 09:45 AM
Hello Everybody,
I have a loop function while using the "Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)" function. I have a spread sheet that loops through wing dings, with conditional formats, so that user can just double click and change the status of items at ease. Everthing worked great, but then i needed to add one more status to the loop and it broke. The error i get in the code below is a Compile Error, stating that "End If without block IF." All help is greatly appreciated, thank you for your time.
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("F11:L43")) Is Nothing Then
If Target.Value = "/" Then Target.Value = "$"
ActiveSheet.Range("A22").Select
Exit Sub
End If
If Target.Value = "O" Then Target.Value = "/"
If Target.Value = "P" Then Target.Value = "O"
If Target.Value = "$" Then Target.Value = "P"
If Target.Value = Empty Then Target.Value = "/"
ActiveSheet.Range("A22").Select
End If
Aug 16 2022 10:30 AM
SolutionPrivate Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("F11:L43")) Is Nothing Then
Select Case Target.Value
Case Is = "/"
Target.Value = "$"
Case Is = "O"
Target.Value = "/"
Case Is = "P"
Target.Value = "O"
Case Is = "$"
Target.Value = "P"
Case Is = Empty
Target.Value = "/"
End Select
ActiveSheet.Range("A22").Select
End If
End Sub
Maybe with these lines of code.
Aug 16 2022 10:31 AM - edited Aug 16 2022 10:32 AM
The last "End If" should be an "End Sub". Change that and it should work.
Aug 16 2022 10:46 AM
Aug 16 2022 10:46 AM
Aug 16 2022 10:56 AM
Aug 16 2022 10:30 AM
SolutionPrivate Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("F11:L43")) Is Nothing Then
Select Case Target.Value
Case Is = "/"
Target.Value = "$"
Case Is = "O"
Target.Value = "/"
Case Is = "P"
Target.Value = "O"
Case Is = "$"
Target.Value = "P"
Case Is = Empty
Target.Value = "/"
End Select
ActiveSheet.Range("A22").Select
End If
End Sub
Maybe with these lines of code.