Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2339
  • Last Modified:

Can Excel unhide/hide rows just by hovering a mouse over it?

We just came upon a very interesting issue.  We need the Excel sheet to have a series of rows hidden (thats easy part) when opening the workbook.  However, when the mouse hovers over those rows, we want it to display them.  When, the mouse, moves away from those rows, it should hide again.

We included a workbook with 2 worksheet.  The worksheet "Sheet with Rows hidden", is when it supposed to be hidden.  The worksheet "Sheet with Rows Visible", is when is visible (when the mouse moves over these 3 rows).
Hidden-Unhidden-EE-.xlsx
0
rayluvs
Asked:
rayluvs
4 Solutions
 
Ingeborg Hawighorst (Microsoft MVP / EE MVE)Microsoft MVP ExcelCommented:
Ramante, as far as I'm aware, Excel does not have such a hover event. The only thing that appears upon mouse hover are cell comments. Other than that, the mouse pointer position does not trigger any events that could be used to start a macro.

cheers, teylyn
0
 
DaveCommented:
In theory in can be done by adding three images from the control box to the areas, one from say rows 7.5 to 10.5 with the unhide code, one above row 7.5 with hide code, one below row 10.5 with hide code

This gives you acces to the MouseOver event, so Image1 for unhide would look like this.

The issue is that the code will keep on running continuously as the mouse moves over the image, so it will be disconcerting for the viewer. Using plain Grouping buttons would be easier

Cheers

Dave

Private Sub Image1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Rows("7:10").Hidden = False
End Sub

Private Sub Image2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Rows("7:10").Hidden = True
End Sub


Private Sub Image3_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Rows("7:10").Hidden = True
End Sub

Open in new window

0
 
DaveCommented:

Actually this works

If you mouse over the two rectangles from E7:I12 (borders left on so you can see them), you will see the top one unhides the rows, the bottom hides the rows

The Boolean variable below stops the redundant re-hide or hide, ie the screen flickering is killed

Cheers

Dave

'normal module

Public bHidden As Boolean
'worksheet code

Private Sub Image1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    If bHidden Then
        Rows("8:10").Hidden = False
        bHidden = False
    End If
End Sub


Private Sub Image2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    If Not bHidden Then
        Rows("8:10").Hidden = True
        bHidden = True
    End If
End Sub

Open in new window

hide.xls
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
Rory ArchibaldCommented:
Wouldn't it be easier to just test the hidden property instead of using a public variable?



Private Sub Image1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    With Rows("8:10")
        If .Hidden Then .Hidden = False
    End With
End Sub

Private Sub Image2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    With Rows("8:10")
        If Not .Hidden Then .Hidden = True
    End With
End Sub

Open in new window

0
 
DaveCommented:
Well it does save one line of code :)
0
 
rayluvsAuthor Commented:
Hey worked great!  ...but what if I want to modify those rows?
0
 
DaveCommented:
No probs
> Hey worked great!  ...but what if I want to modify those rows?
I'm not clear?

if you want to run this on different rows then chnage

 Rows("8:10").Hidden = False
toi
 Rows("X:Z").Hidden = False
where X:Z is your row range, and resize the images
 

Cheers

Dave

0
 
rayluvsAuthor Commented:
No I meant if I wanted to modify those cells.  If we need to change a calculation or add more columns, etc.  I tried to modify and won't let me.
0
 
sijpieCommented:
ramante, Yes it will, but don't click on the image with your mouse: unhide the rows by hovering over, and then move left or right to click on a cell not underneath the image, and /or use the cursor keys to move the cursor into the cell to change.

Brettdj, excellent little 'workaround' you thought of here. I was also going to post about checking the hidden property instead of a public variable, saw that rorya beat me to it...
0
 
DaveCommented:
>  I meant if I wanted to modify those cells.  If we need to change a  calculation or add more columns, etc.  I tried to modify and won't let  me

I'd missed your reply.

If the images are preventing you from editing the cells then you can drag the images away from the cells, then edit the cells and drag the images back to the position

Was that your issue?

Cheers

Dave
0
 
rayluvsAuthor Commented:
sijpie, it worked.   So in conclusion, when changing the "hidden" rows, I just hover over to display the rows, the with the cursor, move to the cells and change any info needed.

Thanx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now