Hello....
A few months ago, a member of this forum helped me with VBA code to double click a cell and jump to another sheet (the code is as below - the first code).
But then I need to modify this sheet so that not only the user can double click it from Column I but also from another column (column G).
I tried to modify the code (second code) and it worked (only seach for a partial match from another column)
My question is whether I can put these 2 codes in the same module?
I tried seaching it, and it seems that I can't put 2 codes in the same module. Can anyone help me how to combine these 2 codes together?
Thank you
The first code.
The second code.
A few months ago, a member of this forum helped me with VBA code to double click a cell and jump to another sheet (the code is as below - the first code).
But then I need to modify this sheet so that not only the user can double click it from Column I but also from another column (column G).
I tried to modify the code (second code) and it worked (only seach for a partial match from another column)
My question is whether I can put these 2 codes in the same module?
I tried seaching it, and it seems that I can't put 2 codes in the same module. Can anyone help me how to combine these 2 codes together?
Thank you
The first code.
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim rFound As Range
If Not Intersect(Target, Range("I6:I31")) Is Nothing Then
If Len(Target.Value) > 0 Then
Cancel = True
Set rFound = Sheets("Items").Columns("A").Find(What:=Target.Value, LookAt:=xlWhole)
If rFound Is Nothing Then
MsgBox Target.Value & " Not found"
Else
Application.Goto Reference:=rFound, Scroll:=True
rFound.EntireRow.Select
End If
End If
End If
End Sub
The second code.
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim rFound As Range
If Not Intersect(Target, Range("G6:G31")) Is Nothing Then
If Len(Target.Value) > 0 Then
Cancel = True
Set rFound = Sheets("Items").Columns("W").Find(What:=Target.Value, LookAt:=xlPart)
If rFound Is Nothing Then
MsgBox Target.Value & " Not found"
Else
Application.Goto Reference:=rFound, Scroll:=True
rFound.EntireRow.Select
End If
End If
End If
End Sub