I have the following code that I like to add to the BeforeDoubleClick event for Sheet3 from code in a module in the same workbook. It looks like I can do something like this but that involves doing .InsertLines for each line of my code. Is there a better way?
Look like I can build a string of my code as well which feels more straightforward. I only have 41 lines so I guess it's not so bad.
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim acct As String
Dim month As String
Dim ws2 As Worksheet
Dim lastRow As Long
Cancel = True
Set ws2 = ThisWorkbook.Worksheets("Sheet2")
With Target.Worksheet
    acct = .Cells(1, Target.Column).Value
    month = .Cells(Target.Row, 1).Value
End With
With ws2
    lastRow = .Cells(.Rows.Count, "C").End(xlUp).Row
    For i = 1 To lastRow
        If .Cells(i, 3).Value = acct Then Exit For
    Next
    For k = i To lastRow
        If .Cells(k, 6).Value = month Then Exit For
    Next
    For m = k To lastRow
        If .Cells(m, 6).Value <> month Then
        s = m
        Exit For
        End If
    Next
    ws2.Activate
    .Range(.Cells(k, 10), .Cells(s - 1, 12)).Select
    Selection.Activate
End With
End Sub
Solved: All I had to do was add
If Sh.Name <> "Sheet3" Then Exit Sub
to the top of my code. Thank you to SJR.
 
    