ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Doube click cell to run macro (https://www.excelbanter.com/excel-programming/443488-doube-click-cell-run-macro.html)

Steve H[_2_]

Doube click cell to run macro
 
Hello
This code will open a calendar when any cell is dbl clicked:

Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)
OpenCalendar
Cancel = True
End Sub


How can I modify to only run if C4 or C6 is clicked?


Thanks!



ManicMiner17

Doube click cell to run macro
 
On 11/08/2010 19:30, Steve H wrote:
Hello
This code will open a calendar when any cell is dbl clicked:

Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)
OpenCalendar
Cancel = True
End Sub


How can I modify to only run if C4 or C6 is clicked?


Thanks!


Perhaps this would work;

Private Sub Worksheet_BeforeDoubleClick _
(ByVal Target As Range, Cancel As Boolean)
Dim iSect As Range

Set iSect = Application.Intersect(Range("c4, c6"), Target)
If Not iSect Is Nothing Then
MsgBox Target.Address '<<< Your calendar code here
End If
End Sub


All times are GMT +1. The time now is 09:34 PM.

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