Thread: [Solved] Hide / unhide Rows
View Single Post
 
Old 12-08-2015, 06:10 PM
charlesdh charlesdh is offline Windows 7 32bit Office 2010 32bit
Expert
 
Join Date: Apr 2014
Location: Mississippi
Posts: 382
charlesdh is on a distinguished road
Default

HI,

Try this code in the worksheet code module.
When you double click in "A1" the code will hide all of the rows to the "1st" empty row.
If you need to do this several time then you will need a different code.
That's why I asked for file to look at. In the file indicate where you need the "Hide" action to take place.

When you double click on range "A1" again it will unhide the rows.

Code:
Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim i As Long
i = Range("A1").End(xlDown).Row
If Target.Column = 1 Then
    Cancel = True
    If Range("A" & Target.Row + 1).Rows.Hidden Then
        Range("A:A").Rows.Hidden = False
    Else
        Range("A" & Target.Row + 1 & ":A" & i + 1).Rows.Hidden = True
    End If
End If
End Sub
Reply With Quote