Hide and unhide rows by selecting a letter from a Combobox

CBS

New Member
Joined
Jan 4, 2007
Messages
33
Hide and unhide rows by selecting a letter from a userform ComboBox

--------------------------------------------------------------------------------

Hi, I have tried for ages .. but cant get it working..

i have a combobox and have A, B, C, as options in the combobox

then I have a table from row 10 to row 50

if A is selected from the combobox, I want excel to show only rows 10 to 20 and hide rows 20 to 50

if b is selected from the combobox, I want excel to show only rows 20 to 30 and hide rows 10 to 20 & 30 to 40

if c is selected from the combobox, I want excel to show only rows 30 to 40 and hide rows 10 to 30 & 40 to 50


in other words, i want all rows 10 to 50 hidden at all times, until a selection A, B, C is made in which i want thoes related rows to be shows and all other rows between rows 10 to 50 hidden...

Could someone please help me

thankyou
 
Can you just run the code and get back to me with the message
Code:
Private Sub ComboBox1_Change()
  Dim myRows

  Me.Rows("218:315").Hidden = True
  Sheets("sheet2").Rows("2963:3357").Hidden = True

  Select Case ComboBox1.Value
    Case "A": myRows = Array("218:242", "2963:3063")
    Case "B": myRows = Array("243:267", "3064:3162")
    Case "C": myRows = Array("268:292", "3163:3261")
    Case "D": myRows = Array("293:315", "3262:3356")
  End Select
  Msgbox isarray(myrows)
  If IsArray(myRows) Then
     Me.Rows(myRows(0)).Hidden = False
     Sheets("sheet2").Rows(myRows(1)).Hidden = False
 End If
End Sub
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top