Apply double click marco function of a cell based on a another cell value in same row

Vincent88

Active Member
Joined
Mar 5, 2021
Messages
382
Office Version
  1. 2019
Platform
  1. Windows
  2. Mobile
Hi, I need help to run a marco by double clicking a cell in E column to run a marco but this can only be implemented if the both Cell A and B in same row is not empty. Below is my code

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Range("A:B" & Rows.Count).Value <> 0 Then
Range("E" & Rows.Count).Activate
End If

If Not Intersect(Target, Range("E" & Rows.Count)) Is Nothing Then
Cancel = True
Call Module8.SelectOLE
End If
End Sub
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
I'm not quite sure I understood what you meant, but here we go.

VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
 If Target.Column <> 5 Or Application.CountA(Cells(Target.Row, 1).Resize(, 2)) < 2 Then Exit Sub
 Cancel = True
 Call Module8.SelectOLE
End Sub
 
Upvote 0
I'm not quite sure I understood what you meant, but here we go.

VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Column <> 5 Or Application.CountA(Cells(Target.Row, 1).Resize(, 2)) < 2 Then Exit Sub
Cancel = True
Call Module8.SelectOLE
End Sub
Hi Osvaldo,
Thank you for your quick response. What I meant is that both cells ( ie : A2 and B2 ) must be non blank, then the double clicking function in E2 works. This applies to all other rows afterward. Appreciate your further insight.
 
Upvote 0
Hi, Vincent.

The code I suggested should work for any cell in column E as you described above.

Remembering (apologise if you already know this) that a copy of the code should be installed in the appropriate sheet module (right click on the sheet tab and choose to "View Code").
 
Upvote 0
Hi, Vincent.

The code I suggested should work for any cell in column E as you described above.

Remembering (apologise if you already know this) that a copy of the code should be installed in the appropriate sheet module (right click on the sheet tab and choose to "View Code").
Hi Osvaldo,
Though I don't quite understand the script but it works. Thank you for your help.
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,862
Members
449,052
Latest member
Fuddy_Duddy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top