+ Reply to Thread
Results 1 to 16 of 16

[VBA] Hiding columns when a certain Value is displayed.

  1. #1
    Registered User
    Join Date
    10-25-2016
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    13

    [VBA] Hiding columns when a certain Value is displayed.

    I have a problem, and I have absolutely no idea how to fix it.

    Let's say, we have a full column with dropdowns. In each dropdown, there's a certain type of data, I'm going to use cars for an example.
    We also have a full line with specifications.

    Now, imagine we go to A1, which is the dropdown column, and we pick Ford (car brand). When I pick Ford, I want excel to hide all the columns EXCEPT the columns with the specification data about Ford.
    Let's say Ford is associated with lines such as Engine, Consumption and Torque, but there's lots and lots of other lines like, Electrical Consumption etc.
    When I pick Ford in the Dropdown, I want excel to hide everything and only display the columns that say "Engine, Consumption and Torque" in a way I can fill them up.
    Now, let's imagine that in the dropdown below, I pick Electric Car Brand. I want Excel to hide all the other columns, and display "Electrical Consumption, *Specification 1* and *Specification 2*

    How am I able to achieve this? The closest thing I've saw are macros, but my level of knowledge on excel is still quite low and I'm not understanding how to get them working. I would love if someone could help me out with this.
    Last edited by Palmajr; 10-26-2016 at 06:26 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,910

    Re: Hiding columns when a certain Value is displayed.

    Please explain how this request differs from the one I answered previously with this solution:

    Excel 2016 (Windows) 32 bit
    B
    C
    D
    E
    F
    G
    H
    I
    19
    Tool Name Brand Product Type Power Electrical Consumption Cutting Depth
    20
    Electrical Saw ES433 AEG Electrical Saw
    Sheet: Folha1

    Excel 2016 (Windows) 32 bit
    E
    19
    =IFERROR(HLOOKUP($D$20,Specifications!$B$2:$D$5,COLUMNS($D$19:E19),0),"")
    Sheet: Folha1
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    10-25-2016
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    13

    Re: Hiding columns when a certain Value is displayed.

    Okay, basically I need to have everything on the same excel page. On the one we discussed, the other data was on another page, and also, when I typed the "Product type" the fields automatically changed, that is correct and so far so good.
    Now, what I need to get done is to have static fields (Doesn't matter how many, can be hundreds) and I need those fields to be shown whenever I change the "Product type".

    I am sorry if it sounds of similar nature, but the problem is completely different

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,910

    Re: Hiding columns when a certain Value is displayed.

    Well, could you please provide another workbook, then? You need to mock up what you want to achieve with some examples of expected outcomes. I suspect that the solution will not in fact be a million miles away from what you have already, but we'll see. Attach the new workbook here.

  5. #5
    Registered User
    Join Date
    10-25-2016
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    13

    Re: Hiding columns when a certain Value is displayed.

    I'll try to.

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,910

    Re: Hiding columns when a certain Value is displayed.

    Thank you - it will help. Just to clarify: will the objective be to filter and display data that already exists OR to enter new data?

  7. #7
    Registered User
    Join Date
    10-25-2016
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    13

    Re: Hiding columns when a certain Value is displayed.

    Here it is. I've explained how I want it to work in the file itself.
    Attached Files Attached Files

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,910

    Re: Hiding columns when a certain Value is displayed.

    I cannot see how this differs from what you asked for before, so answer the following, please: what is the purpose of this? Are you wanting to view data that exists or to add data?

  9. #9
    Registered User
    Join Date
    10-25-2016
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    13

    Re: Hiding columns when a certain Value is displayed.

    Add data. Let me insert an Excel file with something that's already "manually filled" but not fully functional.
    I think you'll understand better that way.
    Basically, in this file, you can see each type of tool and only the fields that correspond to it are filled. I want a simple way to see the fields for that type of tool without having to see the others.
    Attached Files Attached Files

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,910

    Re: Hiding columns when a certain Value is displayed.

    Thanks - yes, it is much clearer now. You are going to need a VBA solution, and I am afraid I am not able to help with this. I would recommend that you go back to your opening post and edit the thread title so that VBA is visible as part of it - this will signal to those who can help that you need VBA.

  11. #11
    Registered User
    Join Date
    10-25-2016
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    13

    Re: Hiding columns when a certain Value is displayed.

    I am so thankful for this, AliGW. I will do this.

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,910

    Re: [VBA] Hiding columns when a certain Value is displayed.

    You're welcome - I hope you get some help soon!

  13. #13
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: [VBA] Hiding columns when a certain Value is displayed.

    Do you want to select something from the dropdown in A1, once selected, it will filter a specific column for that item?
    There is a sample here to AutoFilter as you type
    http://www.excelforum.com/excel-gene...-you-type.html
    I also have an old YouTube example
    https://www.youtube.com/watch?v=E6Nj2vIvlpI

  14. #14
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: [VBA] Hiding columns when a certain Value is displayed.

    This is another approach.

    I assume you know how to build a drop down in D6.

    That done try array entering this in E15 and filling across. If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Dave

  15. #15
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2403
    Posts
    13,406

    Re: [VBA] Hiding columns when a certain Value is displayed.

    Instead of my previous this one is simpler and does not have to be array entered. Enter in D15 and fill across this time.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by FlameRetired; 10-26-2016 at 06:29 PM.

  16. #16
    Registered User
    Join Date
    10-25-2016
    Location
    Portugal
    MS-Off Ver
    2016
    Posts
    13

    Re: [VBA] Hiding columns when a certain Value is displayed.

    I was looking for something like this. Wondering if it's possible for multiple columns.
    https://www.youtube.com/watch?v=Rv-cp0bPGx4

+ 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. Automate hiding columns, adding columns, inserting formulas, and filtering
    By hpatel517 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-27-2016, 11:17 AM
  2. [SOLVED] Hiding and un hiding columns using VBA code
    By Jes1397 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-20-2015, 12:52 AM
  3. Hiding columns in excel without hiding form button
    By rename in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-01-2013, 01:38 AM
  4. Replies: 9
    Last Post: 09-19-2012, 05:31 AM
  5. Un-Hiding and Hiding Columns based on Drop-Down Values in a Column.
    By e4excel in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 10-30-2011, 09:24 AM
  6. Un-Hiding and Hiding Columns based on Drop-Down Values in a Column.
    By e4excel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-11-2011, 06:49 AM
  7. Replies: 2
    Last Post: 10-18-2005, 10:05 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