ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   show a number of rows based upon user input (https://www.excelbanter.com/excel-discussion-misc-queries/184588-show-number-rows-based-upon-user-input.html)

P_R

show a number of rows based upon user input
 
Hey all,

So I want to display only a certain number of rows in a table based upon how
many the user needs (the user will be inputting information into this table,
but that's not really relevant to the problem). I have a cell designated for
them to input their value, and then I want the table to automatically adjust
based on this input.

I've tried feverishly to do this with lists, custom filters, and advanced
filters but have had no luck. Any help would be greatly appreciated!


PS - I've been exposed to VBA, but haven't had much experience with it. I'm
actually hoping that there is an easy way to do this in VBA that my lack of
experience has prevented me from figuring out. That is, if it can't be done
without messing with code.

Stefi

show a number of rows based upon user input
 
Try this macro:

Sub showrows(fromRow, toRow)
Rows("1:" & Rows.Count).EntireRow.Hidden = False
Rows("2:" & fromRow - 1).EntireRow.Hidden = True 'row 1 (header) is
always shown
Rows(toRow + 1 & ":" & Rows.Count).EntireRow.Hidden = True
End Sub

Usage:

Call showrows(20, 40) ' Replace constant figures by your cell values!

Regards,
Stefi

P_R ezt *rta:

Hey all,

So I want to display only a certain number of rows in a table based upon how
many the user needs (the user will be inputting information into this table,
but that's not really relevant to the problem). I have a cell designated for
them to input their value, and then I want the table to automatically adjust
based on this input.

I've tried feverishly to do this with lists, custom filters, and advanced
filters but have had no luck. Any help would be greatly appreciated!


PS - I've been exposed to VBA, but haven't had much experience with it. I'm
actually hoping that there is an easy way to do this in VBA that my lack of
experience has prevented me from figuring out. That is, if it can't be done
without messing with code.



All times are GMT +1. The time now is 11:39 AM.

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