Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
change cell event using circular reference - not VBA! | Excel Worksheet Functions | |||
change cell event using circular reference | Excel Worksheet Functions | |||
problem with cell reference in =sum(offset(cell reference,x,y,z,a)). Want cell ref to be variable. | Excel Worksheet Functions | |||
Triggering an event based on reference | Excel Programming | |||
Converting MouseDown Coordinates to Chart Point Coordinates | Excel Programming |