How to limit "Unhide Rows" Macro?

R

RLY

The "unhide additional rows" macro provided by Jacob works great (below), but
I need to limit the # of rows affected. The max # of additional rows
available is 16, if the user enters "17" an error will occur. How can I apply
this limit?

Thank You, Robert
 
R

Rick Rothstein

If I understand your question correctly, I would think something like this
will work...

With Sheets("Inputs").Select
X = Range("U2")
Y = Range("X2")
If Y - X < 16 Then
Rows(X & ":" & Y).Hidden = False
Range("A" & Y).Activate
Else
MsgBox "You specified too many rows to unhide!"
End If
End With
 
R

RLY

That worked great,
Thank you.

Rick Rothstein said:
If I understand your question correctly, I would think something like this
will work...

With Sheets("Inputs").Select
X = Range("U2")
Y = Range("X2")
If Y - X < 16 Then
Rows(X & ":" & Y).Hidden = False
Range("A" & Y).Activate
Else
MsgBox "You specified too many rows to unhide!"
End If
End With
 

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