ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Is it possible run code when a cell is doubleclicked? (https://www.excelbanter.com/excel-programming/383389-possible-run-code-when-cell-doubleclicked.html)

sumGirl

Is it possible run code when a cell is doubleclicked?
 
Is it possible run code when a cell is doubleclicked?


merjet

Is it possible run code when a cell is doubleclicked?
 
Yes. Suppose you want the code to run if the user clicks on cell B5.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)
If Target.Address = "$B$5" Then
'do something
End If
End Sub

In he VB Editor put this in the worksheet's module.

Hth,
Merjet



sumGirl

Is it possible run code when a cell is doubleclicked?
 

Cool, thanks!


Chip Pearson

Is it possible run code when a cell is doubleclicked?
 
If Target.Address = "$B$5" Then
'do something
End If


You probably want to set Cancel = True in this code:

If Target.Address = "$B$5" Then
'do something
Cancel = True
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

"merjet" wrote in message
ps.com...
Yes. Suppose you want the code to run if the user clicks on cell B5.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)
If Target.Address = "$B$5" Then
'do something
End If
End Sub

In he VB Editor put this in the worksheet's module.

Hth,
Merjet






All times are GMT +1. The time now is 03:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com