+ Reply to Thread
Results 1 to 5 of 5

Dynamically Applying cascade Data Validation to columns

  1. #1
    Registered User
    Join Date
    07-21-2022
    Location
    USA
    MS-Off Ver
    2019
    Posts
    2

    Question Dynamically Applying cascade Data Validation to columns

    Hello Everyone

    I'm optimistic that there's a solution to my issue. I have a dataset as the source (table named "t_Src") and a user input table.

    The goal is to automatically apply data validation to the User Input Table's Databodyrange as the user enters or selects from a dropdown. When nothing is selected in the User Input table, any data validation dropdown should include all options from the source table. However, as soon as the user selects an option from any column, the other columns in the user input table should be re-validated to show only options that match the user's selection. As the user continues to select criteria from any other columns, the data validation should change accordingly. Additionally, if the user deletes any selected criteria, the data should be re-validated for the remaining columns.

    I've managed to achieve this objective using the Advanced Filter function, but it's a bit slow. I also want to avoid looping through the table/array as that also slows down the code. I'm wondering if you have any ideas on how to achieve this faster and more efficiently.

    Thank you for your time and help.
    DV Questions.xlsx

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Dynamically Applying cascade Data Validation to columns

    This one drove me crazy. Pivot table filters are very picky when it comes to numbers and dates. It wants the format EXACTLY as it is shown in the source data. Unfortunately, Excel wants to help you out, so when you select 1.900 as a drop down it converts it into a number 1.9 if you build pivot table using the data you get different results if you use 1.9 or 1.900 for a filter. Formatting the dropdown cell as text still yields 1.9. So the solution for this is "hard coded." I noticed that the format of the OD column is #.000 and of the Wt column #.00. Formatting these cells in code: TargetVal = format (target.value,"#.000") isn't enough you need to convert it into a string: TargetVal = format(target.value,"#.000")&"".

    Sheesh!

    Once I figured that out, I was able to proceed. I use pivot tables to do the heavy lifting.

    The first pivot table has a unique listing of all the OD values. The second pivot table has a list of weights for the selected OD value and so on. I overlaid each pivot table result with a named dynamic range and used these for the dropdowns.

    There is a change event on the CsgData page, so when you select an OD, it sets the filters of OD on the next 3 pivot tables. When you select a Wt it sets that value on the next two pivot tables and so on.

    I think I got this working. The issue I would have is if the format for OD and Wt were inconsistent. I don't know of any way to determine how many zeros are supposed the be trailing after Excel helps me out by dropping them.
    Attached Files Attached Files
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Dynamically Applying cascade Data Validation to columns

    So I just hung up the phone and said, 'I wish I had said." I pressed on a bit after this posting.

    I have a way of finding the format for a selection:
    I select the value in the drop-down box and Excel will drop the trailing decimals. I then use Match to find the first occurence of this value in the data. I than use index to find the cell and run a UDF on it.

    =GetFormat(INDEX(tbl_Src[OD],MATCH(t_DV[@[S_OD]],tbl_Src[OD],0),1))

    Please Login or Register  to view this content.
    In this case it yields 0.000.

  4. #4
    Registered User
    Join Date
    10-03-2022
    Location
    USA
    MS-Off Ver
    19
    Posts
    2

    Re: Dynamically Applying cascade Data Validation to columns

    Thank you so much for your time and help, I think I need to get myself familiar with Pivot table to understand how this is working. Provided solution is working only if the user starts selecting the OD first and then select the other criteria and also when the selected criteria delete it, it doesn't re- adjust the data validation list to new combination.

    I have attached excel file with Macro and solution I have come with, the Input sheet can take any criteria in any order.

    Thank you again for your Time and Help.PE ToolBox_Csg Data Validation_15_New Method 2_Question.xlsm

  5. #5
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Dynamically Applying cascade Data Validation to columns

    You are correct. The validations only cascade from left to right.

+ 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. Replies: 12
    Last Post: 09-29-2020, 10:31 PM
  2. cascade drop down
    By SSJAMES18 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 12-02-2015, 11:25 AM
  3. [SOLVED] Combobx in cascade
    By MADA BLACK in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 11-01-2015, 08:37 PM
  4. [SOLVED] Cascade/Autofill Columns based on last row entry
    By ssss2005 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-28-2015, 07:30 AM
  5. Is it possible to Cascade Data Tables?
    By mot in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-03-2014, 03:54 PM
  6. Validation in cascade...
    By Jehan in forum Excel General
    Replies: 2
    Last Post: 06-19-2007, 08:47 AM
  7. [SOLVED] Cascade Validation
    By matelot in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-17-2005, 10:20 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