+ Reply to Thread
Results 1 to 5 of 5

Hide rows depending on combobox result

  1. #1
    Registered User
    Join Date
    08-21-2013
    Location
    mexico
    MS-Off Ver
    Excel 2010
    Posts
    5

    Hide rows depending on combobox result

    Hi,

    I'm new in VBA programming.
    I have a combo box with 6 options; linked to cel C2
    When I choose the first option I would like to hide row 14, 15, 23, 24, 25, 26, 29, 30, 31, 32, 33, 34 and 35.
    When I choose the second option I would like to hide row 14, 15, 24, 25, 26, 29, 30, 31, 32, 33, 34 and 35.
    When I choose the third option I would like to hide row 15, 25, 26, 34 and 35.
    When I choose the forth option I would like to hide row 25, 26, 34 and 35.
    When I choose the fifth option I would like to hide row 26, 34 and 35.
    When I choose the sixth option I would like to show all.

    I did:

    'Collateral type'
    Private Sub ComboBox1_Change()

    Select Case ComboBox1.Value

    Dim Rng As Range

    Case Is = "1"
    Rows("14:15,23:26,29:36").EntireRow.Hidden = True
    Case Is = "2"
    Rows("14:15,24:26,29:35").EntireRow.Hidden = True
    Case Is = "3"
    Rows("15:15,25:26,34:35").EntireRow.Hidden = True
    Case Is = "4"
    Rows("25:26,34:35").EntireRow.Hidden = True
    Case Is = "5"
    Rows("26:26,34:35").EntireRow.Hidden = True
    Case Is = "6"
    Rows("11:11,35:35").EntireRow.Unhidden = True

    End Select

    End Sub

    But it didn't work..

    Thanks in advance.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Hide rows depending on combobox result

    Hi,

    Try this (see attachment).

    Hope this helps
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    08-21-2013
    Location
    mexico
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Hide rows depending on combobox result

    Thanks very much, that did the trick!

  4. #4
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Hide rows depending on combobox result

    No worries!

    Happy to help

  5. #5
    Registered User
    Join Date
    08-21-2013
    Location
    mexico
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Hide rows depending on combobox result

    Would you happen to know why when I put the code in my real document, it doesn't work automatically? I have to manually run the macro every time I select a different number in the combo box. This doesn't happen in your document.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Hide Rows Depending on Values in Column
    By gerainta in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 05-16-2012, 09:02 AM
  2. unhide or hide rows depending on previous row value
    By tinkerbelle in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-19-2010, 08:54 AM
  3. hide/unhide rows depending on the top input value
    By TiDz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-07-2006, 05:55 AM
  4. hide/unhide rows depending on the top input value
    By TiDz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-07-2006, 04:05 AM
  5. [SOLVED] Hide rows depending on content...
    By Gord in forum Excel General
    Replies: 1
    Last Post: 05-12-2005, 05:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1