Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel 2010+ Hide all rows except a table 1

Status
Not open for further replies.

JasonEnsor

Programmer
Sep 14, 2010
193
GB
Hi Guys,

I’m looking for a little help with hiding rows of data in excel. My user wants a VBA userform that has X number of buttons on and when clicked it filters the worksheet so that only certain data is shown. I have this working at the moment. Due to the nature of the data certain sections of the data might increase in size, so where previously dummydata1 might be in range a1:c5, it might be amended to a1:c9 which means my hiding of rows needs amending. The data on the worksheet isn’t in an easy format to manipulate and client doesn’t really want to change the layout if possible. I thought I could put the data in tables which would solve the range changing issues, however I’m not sure if you can hide all rows except a table.

Any help would be appreciated. Sorry for any typos or badly written sentences and for not sharing code, I am using my phone for this plus have been up since 5:30am and it is now past midnight.

J.

Regards

J.
 
Hi,

I would hope that your table is either a Structured Table or has a Named Range like Database to reference the entire table or has Named Ranges based on Heading Names for each column of data. Short of that you can identify the top-left cell reference with a Named Range, which will “float” as rows are added/deleted above your table, and using the CurrentRegion property, you can define the top row using the Row property and the last row using the Rows.Count.

BTW, I assume that your table is completely isolated from the other data on All sides, by at least one empty row above and below and one empty column to the left and right.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Code:
Sub HideRowsButTable()
'hide all rows
    ActiveSheet.Cells.EntireRow.Hidden = True
'unhide table
    With [MyTopLeftCell]
        .CurrentRegion.EntireRow.Hidden = False
        .Select
    End With
End Sub

Sub UnHideAll()
    ActiveSheet.Cells.EntireRow.Hidden = False
End Sub

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top