Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default How can I use VB code to execute macro when double-clicking cell?

I have a range of cells on Sheet 1 (lets say, range C10:Z500). For each cell
in this range, I want to program it so that when a user double-clicks a cell,
it takes them to the same cell reference on Sheet 2. (i.e. if I click cell
G45 on the first sheet, it takes me to cell G45 on the second sheet). Can
anyone help me with the proper code for this action?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default How can I use VB code to execute macro when double-clicking cell?

try this idea
right click sheet tabview codeinsert thisSAVE
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Target.Column < 1 Then Exit Sub
Application.Goto Sheets("sheet7").Range(Target.Address)
End Sub

--
Don Guillett
SalesAid Software

"JDay01" wrote in message
...
I have a range of cells on Sheet 1 (lets say, range C10:Z500). For each
cell
in this range, I want to program it so that when a user double-clicks a
cell,
it takes them to the same cell reference on Sheet 2. (i.e. if I click
cell
G45 on the first sheet, it takes me to cell G45 on the second sheet).
Can
anyone help me with the proper code for this action?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 380
Default How can I use VB code to execute macro when double-clicking cell?

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Const WS_RANGE As String = "C10:Z500"
Dim rng As Range

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Range(WS_RANGE)) Is Nothing Then
Set rng = Worksheets("Sheet2").Range(Target.Address)
Worksheets("Sheet2").Activate
rng.Select
End If

ws_exit:
Application.EnableEvents = True
On Error GoTo 0
End Sub

This is worksheet event code, which means that it needs to be
placed in the appropriate worksheet code module, not a standard
code module. To do this, right-click on the sheet tab, select
the View Code option from the menu, and paste the code in.

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"JDay01" wrote in message
...
I have a range of cells on Sheet 1 (lets say, range C10:Z500). For each

cell
in this range, I want to program it so that when a user double-clicks a

cell,
it takes them to the same cell reference on Sheet 2. (i.e. if I click

cell
G45 on the first sheet, it takes me to cell G45 on the second sheet).

Can
anyone help me with the proper code for this action?



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
Buttons that appear when double clicking in a cell Leopold Excel Worksheet Functions 1 April 25th 07 08:38 PM
How do i execute a VBA function by clicking on an excel cell? Matthew Excel Discussion (Misc queries) 1 December 7th 05 01:10 AM
Launching a macro by double-clicking on active cell aca Excel Programming 5 August 4th 05 10:08 PM
double clicking on a source cell martin Excel Worksheet Functions 1 February 8th 05 02:09 AM
Clicking on a cell to execute a routine Mark Excel Programming 2 January 27th 04 12:20 PM


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

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

About Us

"It's about Microsoft Excel"