Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default vba, excel, commandbutton1_click() x,y?

is there a way (As in vb6) to pass the x,y cordinates of where yo
pressed on a commandbutton that is on a worksheet to a variable in
macro?

I'm thinking of vb6 :
sub command_up(x,y, shift) (or something similar)
xcord= x
ycord=y
end sub

thank you. you guys are great

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default vba, excel, commandbutton1_click() x,y?

Jim,

The CommandButton does have a "Mouse_Down" and "Mouse_Up" event. Below is
some code assuming you have a commandbutton named "CommandButton1" created
on Sheet1. This should get you started.

Troy

==========================================
On a standard module, declare the following two global variables:
==========================================
Public PsngCursorX As Single
Public PsngCursorY As Single


===================================
On the Sheet1 codepane, include these two Events:
===================================
Private Sub CommandButton1_Click()
MsgBox "Mouse: X=" & PsngCursorX & ", Y=" & PsngCursorY
End Sub

Private Sub CommandButton1_MouseDown(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
PsngCursorX = X
PsngCursorY = Y
End Sub


"jimx " wrote in message
...
is there a way (As in vb6) to pass the x,y cordinates of where you
pressed on a commandbutton that is on a worksheet to a variable in a
macro?

I'm thinking of vb6 :
sub command_up(x,y, shift) (or something similar)
xcord= x
ycord=y
end sub

thank you. you guys are great!


---
Message posted from http://www.ExcelForum.com/



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
Private Sub CommandButton1_Click() Bob Excel Discussion (Misc queries) 2 December 2nd 06 02:14 AM


All times are GMT +1. The time now is 01:32 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"