View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Stefi Stefi is offline
external usenet poster
 
Posts: 2,646
Default 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.