+ Reply to Thread
Results 1 to 2 of 2

Show/Hide Rows based on cell value

  1. #1
    Registered User
    Join Date
    11-11-2021
    Location
    Essen, Germany
    MS-Off Ver
    Professional Plus 2019
    Posts
    1

    Show/Hide Rows based on cell value

    Hello,

    I am currently trying to hide/show entire rows based on a dropdown value.
    The scenario is that if dropdown value is "EV" it is supposed to show certain rows. That works. However if I go to the drop down selection in the next cell and select "Petrol" the rows shown due to "EV" selection in the previous dropdown selection disappears.
    The optimal solution would be that once I select "EV" the rows are shown and do not disappear even if i select "Petrol" in the other drop down selections.

    Attached some screenshot:



    My code currently looks as following:
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$D$12" Or Target.Address = "$F$12" Or Target.Address = "$H$12" Or Target.Address = "$J$12" Or Target.Address = "$L$12" Or Target.Address = "$N$12" Then
    With ActiveSheet
    Select Case Target
    Case "EV"
    CUSTO.Range("A18:A27").Rows.Hidden = False
    CUSTO.Range("A64:A67").Rows.Hidden = False
    Case "Petrol"
    CUSTO.Range("A18:A27").Rows.Hidden = True
    Case "Diesel"
    CUSTO.Range("A18:A27").Rows.Hidden = True
    Case "P-PHEV"
    CUSTO.Range("A18:A27").Rows.Hidden = False
    CUSTO.Range("A64:A67").Rows.Hidden = False
    Case "P-HEV"
    CUSTO.Range("A18:A27").Rows.Hidden = True
    Case "D-HEV"
    CUSTO.Range("A18:A27").Rows.Hidden = True
    Case "D-PHEV"
    CUSTO.Range("A18:A27").Rows.Hidden = False
    CUSTO.Range("A64:A67").Rows.Hidden = False
    Case "P/CNG"
    CUSTO.Range("A18:A27").Rows.Hidden = True
    Case "P/LPG"
    CUSTO.Range("A18:A27").Rows.Hidden = True
    Case "Fuel cell"
    CUSTO.Range("A18:A27").Rows.Hidden = True
    End Select
    End With
    End If
    End Sub


    Thank you for your help
    Dennis
    Attached Images Attached Images

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,336

    Re: Show/Hide Rows based on cell value

    Please see the yellow banner at the top of the page.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ 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. Show/Hide Rows Based On Partial Cell Text
    By Sugarprincess21 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-10-2021, 12:05 AM
  2. Hide or Show rows based off value of cell in that row?
    By dancor31 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 05-17-2017, 01:38 PM
  3. Show Hide Rows based on cell value
    By Juicy2052 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-13-2015, 07:55 AM
  4. Hide Show rows based on cell value true or false using VBA
    By gopal904 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-12-2013, 07:31 AM
  5. Need help to show/hide rows based on values from a cell
    By concurmgr in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-19-2012, 02:56 PM
  6. [SOLVED] Hide/Show rows based on the value in a cell
    By PatRiot199 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-11-2012, 11:52 PM
  7. Show/Hide Specific set of Rows based on Criteria in one cell
    By mrgillus in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-11-2010, 01:26 PM

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