View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Using VB to unhide hidden rows based on user response

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
if Target.count 1 then exit sub
if Target.Address = "$A$15" then
Rows(20).Resize(10).Hidden = True
if Target.Value =1 and Target.Value <= 5 then _
Rows(20).Resize(Target.Value*2).Hidden = False
End if
End Sub

Right click on the sheet tab and select view code. Put in code similar to
the above code.

--
Regards,
Tom Ogilvy

Lost wrote in message
...
I have 10 rows in groupings of 2 (total of 5 groupings) that are
hidden. Based on user input in a cell I want to unhide the rows.

The user will input a number from 1 to 5 in cell A15. Each number is
to unhide 2 rows progressively. (Currently 20/21, 22/23, 24/25, 26/27,
28/29)

Example:
User input of 1 will unhide 20 and 21. An input of 2 will unhide 20,
21, 22, and 23. An input of 3 will unhide 6 rows. Etc.

Can VB do this? (If so where can I find the code or can you write it
here.)

Can it be automatic anytime that cell is changed or will I need to
create a button to run the specified macro code. (The automatic is
better but will take what I can get.)

Any help you can offer would be apprecaited.

Dave