mouseover/mousebutton

feather1000

New Member
Joined
Feb 18, 2009
Messages
14
:confused:I'm trying to write a visual script in Excel 2003. With what i've read. its not quite sure 100% if it would work.


example.

if mouseover.A2:A4 then goto .......



Any help would definately be helpful
 

ajetrumpet

Banned for being rude
Joined
Apr 12, 2008
Messages
569
Office Version
365, 2016, 2007
Platform
Windows
I don't think there is a mouse over event. From the help menu there is only mouseup, mousedown and movemove over a chart, so if you're wanting soemthing to happpen as you move your mouse from over one cell to the next, i don't think you can accomplish it. I would be very surprised if there was an easy solution to this as well...
 

Tom Urtis

MrExcel MVP
Joined
Feb 10, 2002
Messages
11,197
This is possible to achieve with a little API code but you would not want to do that, it will be a continuously running loop to keep the x and y coordinates updated with every mouse move. Also, range A1 and A2's x and y coordinates, as is the case with any cell on the grid, would depend on the row height and column width of those cells, meaning if you widen or narrow column or column 2, or increase or decrease the row height of row 1, then you'd need to update your macro by hard-coding those coordinates after you determine what they are again.

Instead, stick a label control from the active x control toolbox onto range A1:A2. You can use the fill handles with yoru other hand on the Alt key to "snap" the lable into place so it fits perfectly inside that 2-cell range. In the Properties window, delete the caption and set the BackStyle to transparent.

Doubleclick on the Label, which will take you to the woksheet module, and paste in

Code:
Private Sub Label1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Range("D4").Select 'modify for where you want to go
End Sub
Press Alt+Q to return to the worksheet.

Exit Design Mode, there is an icon for that on the control toolbox.

Now when you mouse over A1 and A2, the cells will appear normal but cell D4 will become active.
Press
 

Forum statistics

Threads
1,084,753
Messages
5,379,654
Members
401,620
Latest member
Ankur Teotia

Some videos you may like

This Week's Hot Topics

  • VBA code giving errors and stopping Excel
    Hello Experts, I have this code being used to loop through files in a file path, and copy specific data to another sheet. It is giving me several...
  • Disable MsgBox message
    Morning, I have a userform where if i leave a ComboBox empty i see a MsgBox warning me that i must enter an invoice number. It is this MsgBox i...
  • Macro Recorder into VBA, Copy Paste Data Filled Cells
    Hi Everyone, I have a macro recorder file that takes a selection of data, copies, then pastes into a new sheet on ("A2:B2") The issue is my...
  • Number format changes while pasting into a cell
    Hi, I am trying to paste a number 180204524303 from an email to an excel cell, however, whenever i try to do so , the the paste value appears as...
  • Collating data
    Hello all. Could someone please help. I am trying to pull all column data from multiple sheets (24 I total so far) into 1 master sheet without...
  • Sum Multiple Columns Based on Multiple Criteria
    I am trying to consolidate data by summing columns G through M based on material, plant, vendor, and fiscal year being identical. The period does...
Top