+ Reply to Thread
Results 1 to 7 of 7

Help with creating VBA to filter validation list

  1. #1
    Registered User
    Join Date
    12-11-2010
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    16

    Help with creating VBA to filter validation list

    Hi, I'm new here and found my way through a Google search.

    I know very little about programming using VBA in Excel. I am currently using Excel 2007 at home and work. I am working on a spreadsheet but I'm trying to automatically filter information based on the input in the validation list.

    I have attached an Excel file that I am working on. I was able to search and find a similar issue/resolution to my issue. Found here:
    http://excel.bigresource.com/Track/excel-5DHphNL2/

    Unfortunately, I can't figure out how to make it work for my particular application. I have validation lists next to the cells that are highlighted in yellow.

    I would like for the "Joist Size" list to hide certain rows in 13-101 based on the matching formula result down column B.

    Ex:
    If I choose 8 in the validation list next to "Joist Size", then a formula next to the 8" joists will display 8. I would like the macro to hide any rows from 13-101 that do not contain 8. Of course, All would display all values and other numbers would filter my rows.

    "LL Deflection Ratio" & "Spacing" would hide columns based on the choice in the list.

    Any help would be greatly appreciated!

    TIA

    Evan
    Attached Files Attached Files
    Last edited by emwhite; 12-13-2010 at 02:37 PM.

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Help with creating VBA to filter validation list

    Try this code in the worksheet module.

    There are some changes you need to make to the worksheet.
    The values in the Joist Size list are all numbers formatted as text. Always use General Format or a specific number format for numbers - but never use Text format.

    A helper column is needed (can be hidden), to designate rows relative to joist size. I've chosen column-A. you can use another column, but must revise the code if so.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  3. #3
    Registered User
    Join Date
    12-11-2010
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Help with creating VBA to filter validation list

    Quote Originally Posted by Palmetto View Post
    Try this code in the worksheet module.

    There are some changes you need to make to the worksheet.
    The values in the Joist Size list are all numbers formatted as text. Always use General Format or a specific number format for numbers - but never use Text format.

    A helper column is needed (can be hidden), to designate rows relative to joist size. I've chosen column-A. you can use another column, but must revise the code if so.
    Palmetto, thank you very much for your help! I changed the text for my Joists list to General, as you suggested.

    I did have a helper column in B but I was using an "IF" formula to display it. I guess, I wasn't thinking simplistic, :-). So I changed the code that you gave me to "B" and I copied your values in Column A to my Column B.

    Now, if I want to use the same situation to hide columns, can I just change any of the references of Row to Column? I'm going to try it now to see...wish me luck! lol

    I appreciate your help!
    Last edited by emwhite; 12-12-2010 at 11:35 AM.

  4. #4
    Registered User
    Join Date
    12-11-2010
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Help with creating VBA to filter validation list

    I just noticed that if I choose a size in my drop down and then choose another size, it won't change from one to another.

    Ex:
    I chose 8 and then decided to go to 12, it would hide everything from 8 and then hide row 12 with it but would not display my 12 joists.

    Can you please help me fix this? Thanks again!

  5. #5
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Help with creating VBA to filter validation list

    I will have to backtrack on my comments on using text formats.

    After a bit of testing, regardless of formatting the cells in the look up list, drop down selection cell and helper cells to have the same format, I could not get the rows for 9 1/4 and 11 1/4 to hide/unhide properly.

    Convert your drop down cell, list of joist sizes and the helper cells to text. Make sure all cells have the same format and values
    Move the helper cells to column-B. Clear cell B12, as this is used in the autofilter.

    Rather than looping, filtering is applied which is more efficient.

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    12-11-2010
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Help with creating VBA to filter validation list

    Quote Originally Posted by Palmetto View Post
    I will have to backtrack on my comments on using text formats.

    After a bit of testing, regardless of formatting the cells in the look up list, drop down selection cell and helper cells to have the same format, I could not get the rows for 9 1/4 and 11 1/4 to hide/unhide properly.

    Convert your drop down cell, list of joist sizes and the helper cells to text. Make sure all cells have the same format and values
    Move the helper cells to column-B. Clear cell B12, as this is used in the autofilter.

    Rather than looping, filtering is applied which is more efficient.
    Thanks again for your help.

    I was able to determine on your previous code that I could select all of the different joist sizes without an issue. I had to select one and if I wanted to go to a different size, I had to select All first. Then I could select a new size.

    Your new code will not allow me to select the 9 1/4 or 11 1/4 joist size. I converted everything to Text as you stated. I will also attach a copy of the Excel sheet so far.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    12-11-2010
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Help with creating VBA to filter validation list

    Oops, I just realized that Excel converted my 9 1/4 to 9.25 when I changed the format. Now it seems to be working fine.

    Thanks again!

+ 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