ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to limit "Unhide Rows" Macro? (https://www.excelbanter.com/excel-programming/426815-how-limit-unhide-rows-macro.html)

RLY

How to limit "Unhide Rows" Macro?
 
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

"Jacob Skaria" wrote:


With Sheets("Inputs").Select
x = Range("U2")
Y = Range("X2")
Rows(x & ":" & Y).EntireRow.Hidden = False
Range("A" & Y).Activate
End With



Rick Rothstein

How to limit "Unhide Rows" Macro?
 
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

--
Rick (MVP - Excel)


"RLY" wrote in message
...
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

"Jacob Skaria" wrote:


With Sheets("Inputs").Select
x = Range("U2")
Y = Range("X2")
Rows(x & ":" & Y).EntireRow.Hidden = False
Range("A" & Y).Activate
End With




RLY

How to limit "Unhide Rows" Macro?
 
That worked great,
Thank you.

"Rick Rothstein" wrote:

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

--
Rick (MVP - Excel)


"RLY" wrote in message
...
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

"Jacob Skaria" wrote:


With Sheets("Inputs").Select
x = Range("U2")
Y = Range("X2")
Rows(x & ":" & Y).EntireRow.Hidden = False
Range("A" & Y).Activate
End With






All times are GMT +1. The time now is 08:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com