Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Click event on cell triggers a macro

How can I program an event, such as a double click on a
particular cell in a worksheet, to excute VBA code. Click
events on different cells in that worksheet would trigger
different VBA functions.
Thanks for any help.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Click event on cell triggers a macro


you would need to do something like this.

The code needs to be placed in the worksheet module


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range,
Cancel As Boolean)
Dim SelCell

' identify which cell has been double clicked
SelCell = Target.Column & ", " & Target.Row

Select Case SelCell
Case "2, 3"
place code here

End Select


End Sub


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Click event on cell triggers a macro

Kris,

Use the BeforeDoubleClick event in the code module for the appropriate
sheet. Put the following code in the Sheet's code module:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
Select Case Target.Address(False, False)
Case "A1"
' code for A1
Cancel = True
Case "B2"
' code for B2
Cancel = True
Case "C3"
' code for C3
Cancel = True
Case Else
End Select
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"kris" wrote in message
...
How can I program an event, such as a double click on a
particular cell in a worksheet, to excute VBA code. Click
events on different cells in that worksheet would trigger
different VBA functions.
Thanks for any help.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a double click event for cell? Ayo Excel Discussion (Misc queries) 3 June 6th 08 12:18 AM
Macro triggers Virus Scanner PT New Users to Excel 4 June 21st 07 12:42 AM
On click button event [email protected] Excel Worksheet Functions 1 November 30th 06 04:39 PM
Macro that triggers off a combo box doug1 Excel Discussion (Misc queries) 2 January 24th 06 02:14 PM
CommandBarButton click event Javi Excel Programming 0 November 3rd 03 03:05 PM


All times are GMT +1. The time now is 10:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"