Multiple Worksheet_BeforeDoubleClick function


Hi Everyone,


Would like to know, how to work with multiple Worksheet_BeforeDoubleClick function as I got an error as per below. It seems that it doesn't work when you have more than one Worksheet_BeforeDoubleClick  function. Thanks in advance. Attached were the sample file. 





1 Reply
best response confirmed by rbalza (Contributor)


There can be only one procedure with the same name. So you must combine them into a single procedure:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Dim xCellsA As String
    Dim r As Long
    If Not Intersect(Range("B4:B8"), Target) Is Nothing Then
        Cancel = True
        r = 5 * Target.Row - 14
        xCellsA = r & ":" & r + 4
        If Target.Value = "+" Then
            Rows(xCellsA).Hidden = False
            Target.Value = "-"
            Rows(xCellsA).Hidden = True
            Target.Value = "+"
        End If
    End If
    If Not Intersect(Range("I12:I16,I18:I22,I24:I28,I30:I34,I36:I40,I42:I46,I48:I52,I54:I58,I60:I64,I66:I70"), Target) Is Nothing Then
        Cancel = True
        Select Case Target.Value
            Case "X"
                Target.Value = "P"
            Case "O"
                Target.Value = "X"
            Case Else
                Target.Value = "O"
        End Select
    End If
End Sub