+ Reply to Thread
Results 1 to 17 of 17

Multi-level Data Validation with Lists

  1. #1
    Registered User
    Join Date
    11-03-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    13

    Multi-level Data Validation with Lists

    Hi All,

    I have a persisting problem with the data validation in the second, third, fourth, etc. level.
    I tried to apply all of the suggestions given earlier, but I still fail.

    Please refer to another sample file (DataValidation.XLS) attached.


    This is what I need to do:

    ++++++++++++++
    Constraints:
    - Due to real life daily usage of this file, I can only sort the APMT sheet by the left-most column.
    - The list is growing daily.
    The data configuration must by in "row" configuration, as it is right now. This is to ensure user comfort through simple "insert row" functionality very day.
    - Please do not tell me to re-arrange the data in the sheet APMT.
    ++++++++++++++


    1) In the first worksheet "Dashboard", there are fields G4, G5, G6, ... that all need data validatioon via List entry.

    2) The field "Customer Name" (G4) only allows data from the named range "CustomerName" in worksheet "APMT". I am also able to filter out duplicates through a little VBA code in the sheet's code. ALl this is not the problem...

    3) Depending on the choice in field G4, the selection possibility in field G5 is then narrowed down. For example, if cell G4 = UMC-2, then the selection possibility in cell G5 is narrowed down to the fields at the right side colum "Process" in the sheet "APMT", i.e.
    Lila
    Pink
    Red
    Red

    4) My issue is now this:
    How do I achieve the data validation for cell G6, depending on the choice made in G5 ??
    In the given example, if I choose G5 = Red, then the next cell G6 shall only offer the related content of the right side colum "ProcessKit" in the sheet "APMT", i.e.
    23
    99

    NOTE: I cannot expect the user to re-sort the data again by the next column.


    How can I achieve this?

    Kind regards,
    Sascha
    Attached Files Attached Files

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Multi-level Data Validation with Lists

    What's the difference with this post ?
    Which you didn't reply to...



  3. #3
    Registered User
    Join Date
    11-03-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Multi-level Data Validation with Lists

    Hi snb,

    apologies, I indeed overlooked your reply at the end of my older thread. (well, I could have seen the "reply" icon in the dahsboard. I overlooked it. This is why I started a new thread.
    Again, sorry!

    I looked into your reply with the attached XLS file "0_cockpit" showing one combobox example.

    I have two problems right now:

    1) Looking at the code of the combobox, I cannot see how you "marry" the left column data content (Rod, Nut, Hat) with the combobox. I simply don't understand it.

    2) Well ..., point 1) I could also easily solve with data validation / list for the Cell E7 (Item Category). BUT: My challenge is then to narrow down the list content for the next Cell E9 (Item), so that the combobox or the validation list only displays the related content in the column right of it? That's my actual problem.

    Example:
    If Cell E7 Item Category = "hat", then the combobox/list in Cell E9 shall only propose this related data:

    D6-Round
    D6-Hexagon
    Open Hat
    Closed Hat


    Can you help me on that?

    Kind regards,
    Sascha

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Multi-level Data Validation with Lists

    No.

    You have a complex question, that can be solved with the solution I provided.
    Using validationlists isn't a good idea, given your constraints.
    So you'd better change your requirements or give up the idea to use validationlists.

    In the attachment an improved version. I think it does exactly what you want (and even more, because in case there is only one possible solution the user will not be bothered being forced to choose 5 times an item from a 'list' of 1 item.)
    Attached Files Attached Files

  5. #5
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Multi-level Data Validation with Lists

    @ snb I can't get your improved version to do anything other than change the value in E7.

    What am I missing?

    Provided that some better data organization of data is employed, this seemed to work, but as you pointed out, there was no reply to the thread so who knows.
    Attached Files Attached Files

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Multi-level Data Validation with Lists

    @Marcol

    After having made a choice in the combobox, click it's dropdownbutton again and you will see the list containing the next options. Make a choice again and E9 will be filled, etc.

  7. #7
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Multi-level Data Validation with Lists

    Neat solution, but not obvious to all how it is supposed to work.

    Your explanation clears the mystery. Thanks.

  8. #8
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Multi-level Data Validation with Lists

    @Marcol

    For your convenience I added a colorindicator, that suggests which choice can be made in the combobox.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    11-03-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Multi-level Data Validation with Lists

    @snb

    Thanks you for your additional explanations. I now do understand the usage and the benefit of using only one single combobox that populates all the fields step by step. It is indeed neat, but it is too overwhelming to my users, as they are just not used to that kind of process. They simply want "classic" usage, meaning: Each field has its own combobox, but the selection of combobox 5 depends on the the selection of combobox 4, depending on combobox 3, depending on combobox 2, ...

    My bigest issue is, though:
    I cannot use your proposed approach as a solution in my case, simply due to the fact that I am completely overwhelemd when looking at the code of it. I just don't have that knowledge, to now apply this principle in my actual real life file (which is very much the same principle, but just a couple of fields more...).


    If you have the possibility to de-mystify the code for me, I would appreaciate. If you think it is too much, then never mind. I apprciate your efforts anyway.
    Kind regards,
    Sascha

  10. #10
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Multi-level Data Validation with Lists

    Let's make a start.

    The basic idea is:

    There is a set of possible outcomes (the data in the lookuptable)
    Every time the user makes a choice the set of possible outcome will be reduced based on the user's choices.
    There are several ways of filtering data.
    The more you use filtering in variables (instead of using a sheet) the faster the code will be.
    That's why I decline the methods .AutoFilter or .AdvancedFilter.

    Approach:
    You can make a variable-based database using a String.
    The only thing you have to determine is a separator for records and a separator for fields.
    In this case I use vbCr as Recordseparator and pipeline ("|") as Fieldseparator.
    You can split a String into a database of records using the VBA-method Split (what's in a name ?) and the recordseparator.
    database=split(string,vbcr)

    Having done that the result is a 1-dimensional Array.
    VBA has a built-in method to filter arrays: filter(array, criterion)
    So it will be very simple to filter that 1-dimensional database, based on the user's choices.

    Now 2 problems are left:
    1. how do we convert the data in the sheet 'lookup table' in to a string
    2. how do we present the filtering result in the combobox.

    ad1.
    - first we read all the data into a variant array sq
    - then we read the values in all cells, row by row into the string c01, using pipelines to separate fields and vbCr to separate records.
    Please Login or Register  to view this content.
    - because we want to do this exercise only once we declare c01 to be a private variable, so that we can use it's content in other procedures (Combobox1_Change) in this module (sheet1) as well.

    - The first choice that has to be made is a choice from the options in column A; This means that every time the user starts afresh those options should be shown in Combobox1.
    Because you preferred not to have duplicates we use the most simple VBA-method to create a unique list by putting those unique values in a string (c02).
    And because we want other procedures in this module to use this unique list too we declare this string as a private variable.
    The unique list from column A is assembled by:
    Please Login or Register  to view this content.
    Combobx1 will be populated with these options by:
    Please Login or Register  to view this content.
    ad 2.

    The respective choices the user makes have to be stored, because we need to filter the database based on all previous choices.
    We could do that in a distinct variable, but I prefer to use one of the Combobox's properties. That has already been loaded in memory so why wouldn't we. The property .althtml serves this purpose. Each choice will be strored here seperated by the fieldseparator, so that we can us this string as filteringargument.
    After the user has made a choice we have to do the following:
    - add the new choice to those already stored in .althtml
    Please Login or Register  to view this content.
    - use the property .althtml to filter the database
    Please Login or Register  to view this content.
    - create a new list of unique options in the next (x+1) 'field' of the database adn populate teh Combobox with it
    Please Login or Register  to view this content.
    - if only 1 record is left in the filtered database it's nu use fatigueing the user any longer, so all the fields will be shown.
    Please Login or Register  to view this content.
    The rest of the code has to do with
    - writing to the sheet (not obligatory),
    - preventing redundant looping
    - formatting

    To grasp the VBA methods split, filter, application.transpose, replace, resize, etc. I can't explain better than the VBEditor's help.

  11. #11
    Registered User
    Join Date
    11-03-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Multi-level Data Validation with Lists

    @snb:
    Well ..., first of all apologies for the late reply. I have been in China for business and could not look into the matter further for the last couple of days. There, we also discussed the deployment of this XLS file as it will serve there for some order control.


    To be honest, your explanations improved my understanding to a certain level, but I still have a persisting problem.


    If you look at the attached XLS file "OrderCreator_2", you can see the actual deployment of the data filtering solution:

    1) The user will fill the database in sheet "AMT" daily through new line inserts. The fields
    CustomerName
    Process
    ProcessKit
    PartName
    PartNo
    SerialNo
    will be filled accordingly.

    2) In the front sheet "Dashboard", the user then uses the said combobox to populate the respective colored cells.


    My current issues:

    - I simply don't have the knowledge to modify your code in such a way that the cells will be filled accordingly. I tried to understand in your previous code how your always jump by 2 cells down and then modify it.
    In my actual case, now the jump from "Process" to "ProcessKit" is one cell down, whereby the jump from "Part Name xx" to "Serial Number xx" is from G to AE.

    - Furthermore, once the first set of data population is completed, the user might then do it again (up to maximum 15 times, as there are 15 part number lines). So, I also need to realize the jump down by one line.

    Can you lead me the way on this?


    By the way, there are many more data relationships, such as auto-population of "Part No" upon detecting the "Part Name" and some more, but this is all straight forward and easy. I have excluded these details here.


    Kind regards,
    Sascha
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    11-03-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Multi-level Data Validation with Lists

    Hi, here is the .xls (97...2003) version.
    Attached Files Attached Files

  13. #13
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Multi-level Data Validation with Lists

    See the attachment for your first question.
    Attached Files Attached Files

  14. #14
    Forum Contributor
    Join Date
    01-31-2007
    Location
    Aschaffenburg, Germany
    MS-Off Ver
    Office 2013
    Posts
    104

    Re: Multi-level Data Validation with Lists

    I had a similar issue and solved it by an event macro such as
    Please Login or Register  to view this content.
    followed by module macros like
    Please Login or Register  to view this content.
    The macro code is easy; the work is to assign appropriate user defined names to the subject cells in the validation lists. I did that on a hidden sheet.

    In my code example, Range("defName1_1") refers to the first item in validation list 1, _2 is the 2nd item in that list; "defList2_1" would be the fist validation list for the 2nd column etc.
    range("defHeader?") are the named cells in the headers.

    What do you think?
    Mike 1001
    _________________________
    Let's keep trying, one day we'll succeed!

  15. #15
    Registered User
    Join Date
    11-03-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Multi-level Data Validation with Lists

    @snb:

    1) I found that in your proposed "single combobox" solution, the fields are automatically populated too fast, even if the data combination in the lookup sheet "AMT" should not yet allow it. Refer to the attached XLS file "snb 002":

    Lookup Sheet "AMT":
    UMC-1 Green 34 Part A 666999 222
    UMC-1 Green 34 Part A 666999 223

    Hence, the combobox should force me all the way to the end, selecting the number 222 or 223. But in the current configuration, the system immediately populates the final cell with 222.

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

    2) It took me a while (with my limited knowledge) to actually find out that the single combobox approach does not work for my end users here. I need multiple comboboxes, as to be seen the other attached XLS file "snb 003". Reason being:
    - 1st, I select the Customer ( your single CB proposal still works)
    - 2nd, I select the Process ( your single CB proposal still works)
    - 3rd, I select the ProcessKit( your single CB proposal still works)
    - 4th, I select the (first) PartName ( your single CB proposal still works)

    - 5th, I select the (second) PartName ( your single CB proposal does not work anymore)
    and so on .... all the way to maximum 15 PartNames within one go.

    For all those maximum 15 PartNames, the "header information" in cells G4...G6 must stay constant, and not being deleted everytime. Although it must be logically always the same, our single combobox proposal requires to select the values for G4...G6 everytime anew.

    Consequentially, it would be much easier for the user to just set individual comboboxes.

    ==> Can you lead me the way to do this?

    Regards from Singapore,
    sas

  16. #16
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Multi-level Data Validation with Lists

    You didn't read my last post meticulously enough. I sai it was only an answer to your first question.
    Now you are jumping to conclusions to fast in your last message.

    See the attachment.
    Start by doubleclicking in the selectioncombobox.

    I had to adjust the data in the datasheet too prevent jumping to fast to results (but it is unnecessary to let users make a choice from a 'list' of 1 item).
    If data for 1 customer are being entered: start with a new customer by doubleclicking the selectioncombobox again.
    Because you didn't share the goal of the whole project (before and after) this can only be a partial answer to what you want to achieve.
    Attached Files Attached Files
    Last edited by snb; 12-16-2010 at 01:08 PM.

  17. #17
    Registered User
    Join Date
    11-03-2010
    Location
    Singapore
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Multi-level Data Validation with Lists

    @snb:

    I believe we have a little misunderstanding. I did read your message in detail and understood it.

    It is indeed true that I did not inform about the requirement of "up to 15 part numbers in one go". I only found out myself recently that your previous version of the single combo box version could not address this challenge. But your latest solution solves this. This is actually pretty good. I am just now fighting through your code trying to understand. Thank you for that.

    BUT: Just to be correct:
    There is still the same issue that the cells are populated to fast, without going down to the last possible selection. It is not a matter of an unnecessary "1 item only" list. Take the example in the attached XLS file. When you work your way through

    Customer 1 --> Process 1 --> Kit 1 --> Part1/11111,

    then your current solution still jumps straight to Serial No. 222, but actrually it would need to allow the combo box selection of 222 or 223. (See the yellow highlighted cells in the AMT lookup sheet.

    By the way, of course the "Part No." field could actually be populated automatically when the "Part Name" is known, because these two fields are always logically married together....

    Kind regards,
    Sascha
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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