I am missing something (hide / unhide rows with buttons)

T

Turquoise_dax

There it is again:
This one to hide rows with "info" in column B:

Dim cell As Range
For Each cell In Range("B:B")
If cell = "i" Then Rows(cell.Row).Hidden = True
Next

(Work fine...)

And this one to show them back:

Rows("1:100").Select
Selection.EntireRow.Hidden = False

However, the "show all" button doesn't work once I hit the "hide info"
button...

Please help! Can any1 tell me why?
 
G

Guest

I think that in your Unhide part, Excel cannot select the rows that are
already hidden. You really want to avoid selecting things because it slows
everything down.

Why don't you just use exactly the same code but make them unhidden instead:

Sub Unhide()
Dim cell As Range
For Each cell In Range("B:B")
If cell = "i" Then Rows(cell.Row).Hidden = False
Next
End sub

Or try this if you just want the first 100 rows:

Sub Unhide2()
Dim iRow As integer
For iRow = 1 to 100
Rows(iRow).Hidden = False
Next iRow
End sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top