Solved

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

Posted on 2010-09-14
11
1,396 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:teylyn
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
 
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
My experience with Windows 10 over a one year period and suggestions for smooth operation
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now