Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / General Excel Questions / April 2008

Tip: Looking for answers? Try searching our database.

show a number of rows based upon user input

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
P_R - 21 Apr 2008 22:01 GMT
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 - 22 Apr 2008 08:03 GMT
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,
>
[quoted text clipped - 11 lines]
> experience has prevented me from figuring out. That is, if it can't be done
> without messing with code.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.