Macro to show/hide rows

petejb

New Member
Joined
Feb 6, 2009
Messages
5
I have a simple macro to hide rows, below
what i need is a macro that will hide/unhide a set number of rows below the row where the macro is acivated. i have a list of names approx 100, each with 11 rows of data below them, i want the data below each name to be hidden until the macro is activated.
Sub ShowUnits()
'
' ShowUnits Macro
' Macro recorded 06/02/2009 by pete
'
'
Rows("5:16").Select
Selection.EntireRow.Hidden = False
End Sub
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Try this one,

Code:
Sub Macro1()
    
Rows(ActiveCell.Row + 1 & ":" & ActiveCell.Row + 12).EntireRow.Hidden = False
 
End Sub
 
Upvote 0
Welcome to the Board!

How do we tell the code to differentiate between the names and the 11 rows of data? Is there some characteristic that's unique to the names?
 
Upvote 0
Smitty, have another read of the OP, not sure if I read it right but it looked to me as if he wanted 11 rows below the activecell.

what i need is a macro that will hide/unhide a set number of rows below the row where the macro is acivated
 
Upvote 0
Assuming that column A is populated to the end of the data range, and that there are always 11 rows to hide below the name, and that there are no extra empty rows in there this will hide all for you.

Range is variable so you need to select the cell with the first name before running the macro.

Jason

Code:
Sub hideitall()
For a = ActiveCell.Row To Cells.SpecialCells(xlCellTypeLastCell).Row Step 12
Rows(a + 1 & ":" & a + 11).EntireRow.Hidden = True
Next a
End Sub
 
Upvote 0
thanks for responding jason smitty

this is an example of what i mean
Row
1 persons name Hide button show button
2 hide 11 rows below name
3 show 11 rows below name
4
5
6 this to be repeated for approx 100 names
7
etc
 
Upvote 0
Hi petejb,

Try this lot for size, have you considered a keyboard shortcut to the macro instead of a button on the page?


Unhide 11 rows below the selected name
Code:
Sub showbelowme()
    
Rows(ActiveCell.Row + 1 & ":" & ActiveCell.Row + 11).EntireRow.Hidden = False
 
End Sub

Hide 11 rows below the selected name.

Code:
Sub hidebelowme()
    
Rows(ActiveCell.Row + 1 & ":" & ActiveCell.Row + 11).EntireRow.Hidden = True
 
End Sub

see reply #5 for code to hide below all names http://www.mrexcel.com/forum/showpost.php?p=1831836&postcount=5


Jason
 
Upvote 0
have just tried your macro Jason, it worked to well, it repated and hid over 100 rows, i need it to just hide the next 11 rows so that i am hiding indivual persons data 1 at a time (i will re write to unhide said rows)
pete
 
Upvote 0
Ha sorry pete, think I put a bad description in there.

Try

Code:
sub showall()
cells.entirerow.hidden=false
end sub

to reset the page.
 
Upvote 0

Forum statistics

Threads
1,216,099
Messages
6,128,816
Members
449,469
Latest member
Kingwi11y

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top