Consulting

Results 1 to 2 of 2

Thread: Hide and unhide rows by selecting a letter from a userform ComboBox

  1. #1
    VBAX Newbie
    Joined
    Apr 2012
    Posts
    1
    Location

    Hide and unhide rows by selecting a letter from a userform ComboBox

    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



    Retail Air Force One Shoes

  2. #2
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •