Solved

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

Posted on 2010-09-14
11
1,518 Views
Last Modified: 2012-08-13
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
Comment
Question by:rayluvs
11 Comments
 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 33679180
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
 
LVL 50

Accepted Solution

by:
Dave Brett earned 250 total points
ID: 33679242
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
 
LVL 50

Assisted Solution

by:Dave Brett
Dave Brett earned 250 total points
ID: 33679287

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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 85

Assisted Solution

by:Rory Archibald
Rory Archibald earned 125 total points
ID: 33680718
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
 
LVL 50

Expert Comment

by:Dave Brett
ID: 33681091
Well it does save one line of code :)
0
 

Author Comment

by:rayluvs
ID: 33681191
Hey worked great!  ...but what if I want to modify those rows?
0
 
LVL 50

Expert Comment

by:Dave Brett
ID: 33682234
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
 

Author Comment

by:rayluvs
ID: 33683122
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
 
LVL 6

Assisted Solution

by:sijpie
sijpie earned 125 total points
ID: 33727621
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
 
LVL 50

Expert Comment

by:Dave Brett
ID: 33729895
>  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
 

Author Comment

by:rayluvs
ID: 33733110
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

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is about my first experience with programming Arduino.
My experience with Windows 10 over a one year period and suggestions for smooth operation
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question