PDA

View Full Version : Hide and unhide rows by selecting a letter from a userform ComboBox



hujh2012
04-18-2012, 07:01 PM
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


Replica Dolce & Gabbana Shoes (http://www.gostyleshop.com)



Retail Air Force One Shoes (http://www.af1outlet.com)

Trebor76
04-18-2012, 10:09 PM
Hi there,

The following could be assigned to a command button where the combo box on the the same form is called "cboCategories" (change to suit):


Select Case cboCategories.Value
Case Is = "A"
Rows(10 & ":" & 20).EntireRow.Hidden = False
Rows(21 & ":" & 50).EntireRow.Hidden = True
Case Is = "B"
Rows(20 & ":" & 30).EntireRow.Hidden = False
Rows(10 & ":" & 19).EntireRow.Hidden = True
Rows(31 & ":" & 50).EntireRow.Hidden = True
Case Is = "C"
Rows(30 & ":" & 40).EntireRow.Hidden = False
Rows(10 & ":" & 29).EntireRow.Hidden = True
Rows(41 & ":" & 50).EntireRow.Hidden = True
End Select

HTH

Robert