Announcement

Collapse
No announcement yet.

Excel mouseOver event or something else?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Excel mouseOver event or something else?

    Wondering if there is a way to have a popup box (besides a comment) when a mouse goes over a cell with predefined data? I have 200-250 cells with data that I want hidden. This spreadsheet is a practice test where I need to enter the data my self. Ill say in my mind what should be in the cell and then put the mouse over the cell for a popup and see if what I was thinking is the right answer. I can make all the text white so no one can see it in the cell, then run the mouse over the cell and a popup with the same text will popup in black font? Any ideas?

  • #2
    Re: Excel mouseOver event or something else?

    It requires the use of VBA, using the worksheet_SelectionChange event. There is no mouse-over event in Excel.

    Something along the lines of:

    Code:
    Option Explicit
    
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
        If Not Intersect(Target, Range("A1:E100")) Is Nothing Then
            MsgBox Target.Value
        End If
    
    End Sub
    Adjust the range per your actual workbook ranges.
    AAE
    ----------------------------------------------------

    Forum Rules | Message to Cross Posters | How to use Tags

    Comment


    • #3
      Re: Excel mouseOver event or something else?

      Thanks for the quick reply. I need to sound really noob. Do I add this into the screen that pops up when I press ALT + F11? Im new to coding. Good at excel, but not adding stuff like this. Thanks for your help.

      Comment


      • #4
        Re: Excel mouseOver event or something else?

        Right-click the worksheet tab and choose View Code, then copy/paste the code. Don't forget to adjust the range references, if needed.
        AAE
        ----------------------------------------------------

        Forum Rules | Message to Cross Posters | How to use Tags

        Comment


        • #5
          Re: Excel mouseOver event or something else?

          sweet. I like it but can there be a floating popup? Like it only shows up as the mouse is over the cell and if you move the mouse to the next cell it pops up wiht the new cells value? Right now you have to click the cell and the popup shows up, then click "ok" to close the popup. minor details but so far a great help!! thanks.

          Comment


          • #6
            Re: Excel mouseOver event or something else?

            As I mentioned, there IS NOT a mouse-hover or mouse-over event. The closest you are going to come, without selecting cells is to add a comment box to all the cells and populate the comment box with the cell value. Then you can mouse over the cell and display the content in the comment box.

            Code:
            Option Explicit
            
            Sub Set_Comment_to_Cell_Value()
            
                Dim c As Range
                
                Application.ScreenUpdating = False
                
                For Each c In Range("A1:E100")
                    c.AddComment Text:=c.Value
                Next c
                
                Application.ScreenUpdating = True
            
            End Sub
            AAE
            ----------------------------------------------------

            Forum Rules | Message to Cross Posters | How to use Tags

            Comment


            • #7
              Re: Excel mouseOver event or something else?

              Ill just deal with what it is. Looks good enough for me. I have another post that Im struggling with yif your really bored. I dont know scripting so I cant do much. I had one guy help quite a bit, but if you want to check it out. its out there.

              Comment


              • #8
                Re: Excel mouseOver event or something else?

                If you have another thread in which you want help, then provide a link to the thread in your post or bump the thread if you haven't gotten a response or solution.
                AAE
                ----------------------------------------------------

                Forum Rules | Message to Cross Posters | How to use Tags

                Comment


                • #9
                  Re: Excel mouseOver event or something else?

                  There is an idea that I think could be made to work. I don't have time to play around and write it at the moment, and what follows is probably a bit advanced for you, but someone else may grab the idea and give it a go:

                  You can lay a Forms Image over the cells you want to potentially have the tool-tip for. You then set the Backstyle of this to fmBackStyleTransparent. A forms object has the MouseMove event. With some care and a fair amount of coding you can work out when the mouse is over a particular cell and then bring up a shape containing your text that tracks the pointer.

                  Code:
                  Option Explicit
                   
                  Private Sub Image1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
                      With ActiveSheet.Shapes(2)
                          .Left = X
                          .Top = Y
                      End With
                  End Sub
                  Take a look at this but don't be mistaken, this is not 'nearly there' to turn it into what you want requires quite a bit of work, but in theory it could be done.
                  Attached Files

                  Comment


                  • #10
                    Re: Excel mouseOver event or something else?

                    Got it. Let me see if I can make sense of your code. Thanks for all your help.

                    Comment


                    • #11
                      Re: Excel mouseOver event or something else?

                      While Rob's idea has merit, this certainly seems to be overkill and requires more progamming effort than is needed to accomplish your intended result.
                      The in-cell comment box does this nicely and with very little coding required.
                      AAE
                      ----------------------------------------------------

                      Forum Rules | Message to Cross Posters | How to use Tags

                      Comment


                      • #12
                        Re: Excel mouseOver event or something else?

                        I just said it was an idea. I didn't say it was a good idea

                        Comment

                        Working...
                        X