+ Reply to Thread
Results 1 to 4 of 4

Hiding/Unhiding columns based on a dropdown list

  1. #1
    Registered User
    Join Date
    03-25-2006
    Posts
    32

    Hiding/Unhiding columns based on a dropdown list

    On my worksheet i have markets going horizontally with each market taking up 2 columns. For instance, market 1 would take up columns E&F with each subsequent market after that taking up 2 more columns all the way to columns FG&FH (lot of markets).

    So what i want to do is create a dropdown list in column A that has a list of markets, obviously simple. However what i'd like to do is have a macro that hides all columns that don't pertain to market in the dropdown.

    So as an example, lets say in the dropdown the user picks "Market 4" and "Market 4" are columns M&N. What i'd like the macro to do is go through and hide the other columns that are not M&N so the user can enter the information.

    Then when they are done entering information the macro will unhide all columns again.

    --------------------

    The reason for this type of fuction is to enter cost data and to not mistakenly enter it into a wrong market. Does this sound doable? I have been searching through the posts and trying to find a macro that would work and not having luck.

    thanks for any help.

  2. #2
    Registered User
    Join Date
    03-25-2006
    Posts
    32
    Something that might help that i thought of was i put in an extra line and established an IF(OR( statement that rides off of the dropdown list.

    Here is what the statement says:

    =IF(OR(A2=all,A2=F3),"",hide)

    A2 is the dropdown list and F3 is the link to the name of the market so that way when the user picks "all" in the droplist all the markets should be shown and when they pick a particular market all markets (except the market chosen) would say "hide" above it.

    Now i think a simple macro could be created that would run through my row (horizontally) and just hide the columns that say "hide" yes? It would need to run everytime something is changed in that dropdown.

    Would this be easier?
    Thanks

  3. #3
    Registered User
    Join Date
    03-25-2006
    Posts
    32
    Here's an example that i found that worked but not exactly how i want. Here's the code:

    Please Login or Register  to view this content.
    I got this to work and it does hide all the columns that have no data in them. However i would like to modify the above code so that when the marco searches through the range it only hides the columns that say "hide." I tried changing the "_" to "hide" but the marco then gets stuck on the application.sum(col)=0 which i'm assuming is trying to sum all the data. Even if i take that out of the code it still won't work.

    Thanks for any help

  4. #4
    Registered User
    Join Date
    03-25-2006
    Posts
    32
    ok, what i did was change my IF(OR( statement around to either input a 1 or a blank so that the marco i posted would work based on the sum function.

    Now i just need to assign the marco to the dropdown. If i have trouble with that i'll post again.

    Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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