+ Reply to Thread
Results 1 to 9 of 9

hide/unhide rows on dropdown selection VBA

  1. #1
    Registered User
    Join Date
    08-08-2014
    Location
    Romania
    MS-Off Ver
    2010
    Posts
    31

    hide/unhide rows on dropdown selection VBA

    Hi.

    I'm relatively new to VBA and somewhat inexperienced.

    I'm trying to write a Sub in VBA which hides certain rows depending on a value selection (a list of nr, from 2 to 5) in a dropdown list.

    Here's the code so far, i used Case Select but tried with IF too, wrote a Macro and a Sub too. It still doesn't work as it should.

    ---

    If Not Intersect(Target, Range("C71")) Is Nothing Then

    Select Case Range("C71")

    Case "A single method": Call Macro_RC2
    Case "More than one method": Call RC_nou

    End Select
    End If

    ---

    Private Sub RC_nou()
    Range("C72:C77").Value = ""
    Rows("72:78").EntireRow.Hidden = False
    Select Case Range("C72")

    Case "2"
    Rows("74").EntireRow.Hidden = False
    Rows("75:77").EntireRow.Hidden = True

    Case "3"
    Rows("76:77").EntireRow.Hidden = True
    Rows("74:75").EntireRow.Hidden = False

    Case "4"
    Rows("77:77").EntireRow.Hidden = True
    Rows("74:76").EntireRow.Hidden = False
    Case "5"
    End Select

    End Sub

    The Macro is working fine, but this sub is not working as it should, it doesn't hide the rows when it should, depeding on the selection.
    can you please help me solve this?

    Thank you in advance!

  2. #2
    Forum Contributor lancer102rus's Avatar
    Join Date
    04-02-2014
    Location
    Ufa
    MS-Off Ver
    Excel 2010, 2013
    Posts
    252

    Re: hide/unhide rows on dropdown selection VBA

    The problem is:

    Please Login or Register  to view this content.
    first you delete data from C72, and only then use Select

  3. #3
    Registered User
    Join Date
    08-08-2014
    Location
    Romania
    MS-Off Ver
    2010
    Posts
    31

    Re: hide/unhide rows on dropdown selection VBA

    yes, i don't know how to clear data, if i don't delete data then it remains there.

    I need it to work every time i operate a change, if i set "2" and then "a single method" the cell C72 has data, even if it's hidden, and then if i set 2 or 3 again it already contains data.

    What should I change?

  4. #4
    Forum Contributor lancer102rus's Avatar
    Join Date
    04-02-2014
    Location
    Ufa
    MS-Off Ver
    Excel 2010, 2013
    Posts
    252

    Re: hide/unhide rows on dropdown selection VBA

    put
    Please Login or Register  to view this content.
    at the end of the sub. That`s all.

  5. #5
    Registered User
    Join Date
    08-08-2014
    Location
    Romania
    MS-Off Ver
    2010
    Posts
    31

    Re: hide/unhide rows on dropdown selection VBA

    ok, i did that. But it still doesn't work.

  6. #6
    Forum Contributor lancer102rus's Avatar
    Join Date
    04-02-2014
    Location
    Ufa
    MS-Off Ver
    Excel 2010, 2013
    Posts
    252

    Re: hide/unhide rows on dropdown selection VBA

    May be need this?
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    08-08-2014
    Location
    Romania
    MS-Off Ver
    2010
    Posts
    31

    Re: hide/unhide rows on dropdown selection VBA

    i already tried it, it does not work. I select 2 and it does nothing.

  8. #8
    Forum Contributor lancer102rus's Avatar
    Join Date
    04-02-2014
    Location
    Ufa
    MS-Off Ver
    Excel 2010, 2013
    Posts
    252

    Re: hide/unhide rows on dropdown selection VBA

    because your macro starts only when C1 changes, and you trying to change C2

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    08-08-2014
    Location
    Romania
    MS-Off Ver
    2010
    Posts
    31

    Re: hide/unhide rows on dropdown selection VBA

    thank you so much, now it seems it works!

+ 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. Hide/Unhide a Selection of Rows
    By EngineerCora in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-22-2013, 03:57 AM
  2. Replies: 1
    Last Post: 05-14-2013, 06:46 PM
  3. [SOLVED] How to hide & unhide rows based on selection from drop down box?
    By jgomez in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-02-2013, 08:30 PM
  4. Hide/Unhide rows on multiple sheets when dropdown selected from sheet 1
    By tammhelp in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-02-2012, 10:33 PM
  5. Hide/Unhide rows Based on Value from Dropdown Lists
    By 2Deep in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-12-2010, 09:43 PM

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