Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm designing a form where Cell A5, which is named Off_Num. This cell
has Values (Select One, 1 to 20) in a dropdown, and Rows 9 to 28 are hidden. Now if 1 is selected in Off_Num cell then, the code should Unhide Row 9. And if 2 is selected then Row(9:10) should be unhidden so on, till if 20 is selected the Rows(9:28) should be unhidden. And if Select One option is selected that Rows(9:28) should get hidden again. Mr. JE McGimpsey'S Reply One way: Put this in your worksheet code module: Private Sub Worksheet_Change(ByVal Target As Excel.Range) With Range("Off_Num") If Not Intersect(.Cells, Target) Is Nothing Then Application.ScreenUpdating = False Rows("9:28").Hidden = True If IsNumeric(.Value) Then Rows("9:9").Resize(CLng(.Value)).Hidden = False End If Application.ScreenUpdating = True End If End With End Sub This code Hides and unhides single row. Now how can I modify this code to unhide a set of rows. My form has a cell named Mod_Num which has values (Select one, 1to5) in a dropdown. The code has to work in such a way that when I select 1, in cell Mod_Num then rows range (17:22) should unhide. On selecting 2, rows (17:27) should unhide. On selecting 3, rows (17:32) should unhide. On selecting 4, rows (17:36) should unhide. And lastely on selecting 5 the complete row range (17:41) should unhide. On selecting Select one from drop down the row range(17:36) should hide. The above code works for unhiding single rows, so I think little modification needs to be made for the above code to unhide set of rows. Please help me modify this code. Thanks for your help. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Code to Unhide Rows using Macro | Excel Worksheet Functions | |||
Enabling option „Format rows“ to hide/unhide rows using VBA-code? | Excel Discussion (Misc queries) | |||
unhide row does not unhide the hidden rows | Excel Worksheet Functions | |||
VB Code to hide and unhide rows | Excel Discussion (Misc queries) | |||
Code for button to hide/unhide rows | Excel Worksheet Functions |