Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default get reference to cell from mousedown event

I have several activeX image controls on a worksheet. When the user clicks on
an image I would like to return a reference to the worksheet cell underneath.
Unfortunately the "me" keyword does not return the name of the control,
otherwise I could use "me" and TopLeftCell. Maybe I could work with the x & y
co-ords returned by the MouesDown event?
Any Ideas?
--
David
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default get reference to cell from mousedown event

An Image control will have a click event. Obviously, since you write the
code for the click event, you already know which control it belongs to. You
can then use that information to get the topleftcell.

Private Sub Image1_Click()
MsgBox Image1.TopLeftCell.Address
End Sub


--
Regards,
Tom Ogilvy


"David" wrote in message
...
I have several activeX image controls on a worksheet. When the user clicks

on
an image I would like to return a reference to the worksheet cell

underneath.
Unfortunately the "me" keyword does not return the name of the control,
otherwise I could use "me" and TopLeftCell. Maybe I could work with the x

& y
co-ords returned by the MouesDown event?
Any Ideas?
--
David



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default get reference to cell from mousedown event

Thanks Tom,
I will be using many images on the same worksheet. Each one will be over a
different cell. I would really like to not have to use the name of each image
control to determine which image control the user clicked on. I would like to
have the mouseDown event handling code for each image control to be the same,
minimising the scope for errors, if possible. I know that the mousedown event
procedure returns the screen x & Y co-ords. Could these be used in some way
to either reference the cell or the name of the image control?
--
David


"Tom Ogilvy" wrote:

An Image control will have a click event. Obviously, since you write the
code for the click event, you already know which control it belongs to. You
can then use that information to get the topleftcell.

Private Sub Image1_Click()
MsgBox Image1.TopLeftCell.Address
End Sub


--
Regards,
Tom Ogilvy


"David" wrote in message
...
I have several activeX image controls on a worksheet. When the user clicks

on
an image I would like to return a reference to the worksheet cell

underneath.
Unfortunately the "me" keyword does not return the name of the control,
otherwise I could use "me" and TopLeftCell. Maybe I could work with the x

& y
co-ords returned by the MouesDown event?
Any Ideas?
--
David




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default get reference to cell from mousedown event

Again, the mousedown event would be a separate event for each image control
and in each event, you would know the name of the image control. If you
wanted to have a common procedure to perform an action, you could call this
procedure from each separate mousedown event and pass in the respective
image control.

The X and Y coordinates on the mouse down event are relative to the top left
corner of the image control, so you would need to know the control to
utilize that information.

the only other alternative is to use a class module as illustrated by John
Walkenbach - in this case, you would have a reference to the image control
and could use the topleftcell directly.

http://j-walk.com/ss/excel/tips/tip44.htm
Handle Multiple UserForm Buttons With One Subroutine


although for commandbutton on a userform, the technique is readily adaptable
to image controls on a worksheet.

--
Regards,
Tom Ogilvy

"David" wrote in message
...
Thanks Tom,
I will be using many images on the same worksheet. Each one will be over a
different cell. I would really like to not have to use the name of each

image
control to determine which image control the user clicked on. I would like

to
have the mouseDown event handling code for each image control to be the

same,
minimising the scope for errors, if possible. I know that the mousedown

event
procedure returns the screen x & Y co-ords. Could these be used in some

way
to either reference the cell or the name of the image control?
--
David


"Tom Ogilvy" wrote:

An Image control will have a click event. Obviously, since you write

the
code for the click event, you already know which control it belongs to.

You
can then use that information to get the topleftcell.

Private Sub Image1_Click()
MsgBox Image1.TopLeftCell.Address
End Sub


--
Regards,
Tom Ogilvy


"David" wrote in message
...
I have several activeX image controls on a worksheet. When the user

clicks
on
an image I would like to return a reference to the worksheet cell

underneath.
Unfortunately the "me" keyword does not return the name of the

control,
otherwise I could use "me" and TopLeftCell. Maybe I could work with

the x
& y
co-ords returned by the MouesDown event?
Any Ideas?
--
David






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
change cell event using circular reference - not VBA! Dan Excel Worksheet Functions 3 June 17th 08 03:26 PM
change cell event using circular reference Dan Excel Worksheet Functions 3 June 17th 08 10:32 AM
problem with cell reference in =sum(offset(cell reference,x,y,z,a)). Want cell ref to be variable. [email protected] Excel Worksheet Functions 2 December 11th 04 12:05 AM
Triggering an event based on reference Supriya Excel Programming 0 January 29th 04 11:50 AM
Converting MouseDown Coordinates to Chart Point Coordinates Steve[_50_] Excel Programming 3 December 2nd 03 06:48 PM


All times are GMT +1. The time now is 07:41 AM.

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"