Macro to unhide the nest row


Posted by Greg on March 07, 2001 8:12 AM

I need a macro that will unhide the next row. For example,
the first time I run it, it will unhide row 4. The next
time, it unhides row 5, then row 6, etc. Any ideas?

Posted by ml on March 07, 2001 2:08 PM

Will rows 4+ initially start as hidden?
If that's true, you could have something like:

Sub Row_Unhiding()
R = 4
Do Until Rows(R).Hidden = True
R = R + 1
If R > 16536 Then
MsgBox "No more rows to unhide!", vbCritical, "Error"
Exit Sub
End If
Loop
Rows(R).Hidden = False
End Sub

Posted by Greg on March 07, 2001 2:31 PM

Thanks! But its not quite working correctly. I want to unhide only the next unhidden row.
it keeps returning the "no more rows to unhide" error, but does not
unhide anything. Any suggestions?



Posted by ml on March 08, 2001 10:09 AM

The macro as written starts on row 4, checks to see if it is hidden,
and goes to the next row if it is visible. Once it finds the first hidden
row (starting its search on row 4), it will unhide that row and stop the macro.
If it gets to the bottom of the sheet and doesn't find any hidden rows, the
macro gives the "no more rows to unhide" error.

Rows are hidden if you selected them earlier and did Format->Row->Hide
or if you set them to height = 0.

The macro also runs on the sheet that is active when you execute the macro.

Let me know if you still have difficulties.