ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using VB to unhide hidden rows based on user response (https://www.excelbanter.com/excel-programming/274691-using-vbulletin-unhide-hidden-rows-based-user-response.html)

Lost[_2_]

Using VB to unhide hidden rows based on user response
 
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

Tom Ogilvy

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




RU_Powers

Using VB to unhide hidden rows based on user response on a different sheet
 
On Tue, 19 Aug 2003 00:46:31 -0400, "Tom Ogilvy"
wrote:

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.


Tom O provided some great code to hide/unhide rows on a sheet based on
a user input. I am running into a slight problem I need a little
guidance.

I have Sheet 1 and Sheet 5. I want the input from Sheet 1 to modify
the rows on sheet 5. I know this is wrong code but it is what I have
so far:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
' Checks Part Time Labor Types
If Target.Count 1 Then Exit Sub
If Target.Address = "!Sheet1$F$16" Then
Rows(8).Resize(7).Hidden = True
If Target.Value = 1 And Target.Value <= 5 Then _
Rows(8).Resize(Target.Value + 2).Hidden = False
End If
End Sub

I know the problem lies with the 4th live down. I want the user input
from cell F16 on sheet one to effect the rows on sheet 5. (In this
case row 8 and the following 7 rows.)

Can someone help fine tune that 4th line.

Thanks

RU


All times are GMT +1. The time now is 11:56 PM.

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