+ Reply to Thread
Results 1 to 25 of 25

Data Validation Listing Based on Certain Condition

  1. #1
    Registered User
    Join Date
    12-13-2010
    Location
    India
    MS-Off Ver
    Office 365
    Posts
    18

    Data Validation Listing Based on Certain Condition

    Dear Gurus,

    Can we have Data validation list based on certain criteria. For example in data validation drop down, when I select 'Apr' it should list down only April month related weeks in another data validation column.

    Sample data provided below:
    Data validation list maintained in separate sheet
    02-Apr-15 To 08-Apr-15 Apr
    09-Apr-15 To 15-Apr-15 Apr
    16-Apr-15 To 22-Apr-15 Apr
    23-Apr-15 To 29-Apr-15 Apr
    30-Apr-15 To 06-May-15 Apr
    07-May-15 To 13-May-15 May
    14-May-15 To 20-May-15 May
    21-May-15 To 27-May-15 May
    28-May-15 To 03-Jun-15 May
    04-Jun-15 To 10-Jun-15 Jun
    11-Jun-15 To 17-Jun-15 Jun
    18-Jun-15 To 24-Jun-15 Jun
    25-Jun-15 To 01-Jul-15 Jun
    02-Jul-15 To 08-Jul-15 Jul
    09-Jul-15 To 15-Jul-15 Jul
    16-Jul-15 To 22-Jul-15 Jul
    23-Jul-15 To 29-Jul-15 Jul
    30-Jul-15 To 05-Aug-15 Jul
    06-Aug-15 To 12-Aug-15 Aug
    13-Aug-15 To 19-Aug-15 Aug
    20-Aug-15 To 26-Aug-15 Aug
    27-Aug-15 To 02-Sep-15 Aug

    In the new sheet there should be two columns, Week & Month with data validation. When I select Apr from the drop down, the week column should list down only April month related weeks.

    Please advise how to achieve this...

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

    Re: Data Validation Listing Based on Certain Condition

    I made some assumptions. One: these are strings and not dates. Two: if the beginning or end contains the month then you want to see it.

    I made a helper column in column B with the formula: =ISNUMBER(FIND($E$1,A2)). Cell E1 contains the month you want. Find will give the number position that this substring is found in Cell A2. If the substring doesn't exist in Cell A2, then Find produces an error. Wrapping Find in ISNUMBER means it will yield TRUE is the substring is found and False if it is not.

    The list you want to look at is determined by a named dynamic range: MyWeeks =OFFSET(Sheet1!$B$2,MATCH(TRUE,Sheet1!$B$2:$B$23,0)-1,-1,COUNTIF(Sheet1!$B$2:$B$23,TRUE),1).

    See this article for information on how to use the offset command to make a named dynamic name.: http://www.utteraccess.com/wiki/inde...Dynamic_Ranges.

    I included a couple of intermediate calculation on the worksheet in column G. These aren't necessary for the named range to work. The formulas contained in these cells are part of the named dynamic range. I just included them on the worksheet to help you visualize what's going on. Notice how these cells change and how the Valid column changes when you change the month in Cell E1.

    The dropdown in Column H reflects the desired weeks.
    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
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,946

    Re: Data Validation Listing Based on Certain Condition

    I would suggest that you upload a small (clean) sample workbook (not a pic) of what you are working with, and what your expected outcome would look like.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    12-13-2010
    Location
    India
    MS-Off Ver
    Office 365
    Posts
    18

    Re: Data Validation Listing Based on Certain Condition

    Attaching the sample file for your reference...

    Quote Originally Posted by FDibbins View Post
    I would suggest that you upload a small (clean) sample workbook (not a pic) of what you are working with, and what your expected outcome would look like.
    Attached Files Attached Files

  5. #5
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Data Validation Listing Based on Certain Condition

    In your Weeks sheet, would there be more than one set of APRIL weeks (i.e. 2016, then further down the sheet 2015, etc)?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Data Validation Listing Based on Certain Condition

    Assuming the answer to my last question was yes, I did it this way
    In Weeks! col D, I changed the formula to
    In D2 copied down
    =TEXT(A2, "mmm")

    In E2 (you can hide this column later)
    =IF(D2=Data!$A$2,D2&COUNTIF($D$1:$D2,D2),"")
    this creates a unique list of April (or whatever month is chosen in Data!

    In G2 copied down to G19 (because I figured that was far enough)

    =IFERROR(INDEX($C$2:$C$27, MATCH(Data!$A$2&ROWS($G$2:$G2), Weeks!$E$2:$E$27,0)),"")
    that pulls the appropriate month over to a congruous list

    I created 2 defined names (in Formula Tab of ribbon)
    Lastrow =MAX((LEN(Weeks!$G$2:$G$19)>0) * ROW(Weeks!F2:F19))-1

    and
    List =Weeks!$G$2:INDEX(Weeks!$G$2:$G$19, Lastrow)

    Then for your data validation in Data!B2
    =List
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    12-13-2010
    Location
    India
    MS-Off Ver
    Office 365
    Posts
    18

    Re: Data Validation Listing Based on Certain Condition

    Hi ChemistB,

    Its working perfectly for only one row. In your sample file also you have tested with data validation for only one row.

    How to do it data validation with multiple rows? for example, the first row column A, I'll select Apr and the second row column A, I'll select May.

    Regards,
    Suresh
    Quote Originally Posted by ChemistB View Post
    Assuming the answer to my last question was yes, I did it this way
    In Weeks! col D, I changed the formula to
    In D2 copied down
    =TEXT(A2, "mmm")

    In E2 (you can hide this column later)
    =IF(D2=Data!$A$2,D2&COUNTIF($D$1:$D2,D2),"")
    this creates a unique list of April (or whatever month is chosen in Data!

    In G2 copied down to G19 (because I figured that was far enough)

    =IFERROR(INDEX($C$2:$C$27, MATCH(Data!$A$2&ROWS($G$2:$G2), Weeks!$E$2:$E$27,0)),"")
    that pulls the appropriate month over to a congruous list

    I created 2 defined names (in Formula Tab of ribbon)
    Lastrow =MAX((LEN(Weeks!$G$2:$G$19)>0) * ROW(Weeks!F2:F19))-1

    and
    List =Weeks!$G$2:INDEX(Weeks!$G$2:$G$19, Lastrow)

    Then for your data validation in Data!B2
    =List

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,363

    Re: Data Validation Listing Based on Certain Condition

    See attached:

    I ad a Worksheet Change macro which puts the selected month from column A into G2: the latter is hidden with font=white

    Please Login or Register  to view this content.
    The following formula were changed in Weeks:

    in E2 =IF(D2=Data!$G$2,D2&COUNTIF($D$1:$D2,D2),"")

    in G2

    =IFERROR(INDEX($C$2:$C$27, MATCH(Data!$G$2&ROWS($G$2:$G2), Weeks!$E$2:$E$27,0)),"")

    If you want to use cell other than G2 change all references to G2 to new cell.
    Attached Files Attached Files
    Last edited by JohnTopley; 04-01-2016 at 11:50 AM.

  9. #9
    Registered User
    Join Date
    12-13-2010
    Location
    India
    MS-Off Ver
    Office 365
    Posts
    18

    Re: Data Validation Listing Based on Certain Condition

    Hi John,
    Still it is working for only one line item... Please check the attached file, data sheet...
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,363

    Re: Data Validation Listing Based on Certain Condition

    You don't need a formula in G2: the macro just inserts the chosen month for use by the other formulas provided by ChemistB.

  11. #11
    Registered User
    Join Date
    03-31-2016
    Location
    Alberta, Canada
    MS-Off Ver
    2010
    Posts
    8

    Re: Data Validation Listing Based on Certain Condition

    Hello,
    The sheet I am currently working in has been setup for techs to enter field results and lab testing results with conditional formatting used to colour code results when outside a few parameter sets to quickly alert possible concern areas for managers to view easily.All the formatting works great except I am stuck on the formula to meet the last parameters and need help. All CF is determined from what is entered into the cell based on data from other cells. However the last one is based on Column A that contains alpha numeric batch codes. The Cell in Column P needs to be formatted Red based on the number entered being less than the target in Column N only when either codes 30C20IW or 30D10DW appear in Column A (from a massive drop down list referenced on another page).
    What is the formula to combine the different conditions; so the new format based on these new requirements applied only when the two specic codes appear?

  12. #12
    Registered User
    Join Date
    12-13-2010
    Location
    India
    MS-Off Ver
    Office 365
    Posts
    18

    Re: Data Validation Listing Based on Certain Condition

    John,

    I don't see any macros in your sheet...
    Quote Originally Posted by JohnTopley View Post
    You don't need a formula in G2: the macro just inserts the chosen month for use by the other formulas provided by ChemistB.

  13. #13
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,363

    Re: Data Validation Listing Based on Certain Condition

    The macro is the Sheet "Data" : Right click on tab and "View Code"

  14. #14
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,363

    Re: Data Validation Listing Based on Certain Condition

    @CWALES: please start your own thread.

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

    Re: Data Validation Listing Based on Certain Condition

    Another formula approach.

    In Weeks sheet month headers are in E1:P1.

    Then this array-entered formula in E2 filled down and across to P9 or until you get all blanks under each month.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    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.

    Then redefine the Data validation formula for B2 in the Data sheet as
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    It is important to make sure the $A2 reference in the formula is set relative to row.

    Then redefine Data validation for A2 to
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Fill the drop downs in A2 and B2 down as needed.
    Dave

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

    Re: Data Validation Listing Based on Certain Condition

    Correction.

    Data validation for A2 doesn't need to be changed. I was unable to edit my above post.

  17. #17
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,363

    Re: Data Validation Listing Based on Certain Condition

    Dave,
    When I tested, the last week of previous month appeared in the dropdown.

    John

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

    Re: Data Validation Listing Based on Certain Condition

    John,

    Yes. The items in the drop down change, but the previous selection remains until another selection is made from the new list. I've seen methods for clearing the previous B2 selection. They all involve conditional formatting, but I do not recall how that is done. Cosmetic only. If a formula depends upon that cell it won't return correctly until a new item is selected.

    You have any ideas?

    Dave
    Last edited by FlameRetired; 04-01-2016 at 01:50 PM.

  19. #19
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,363

    Re: Data Validation Listing Based on Certain Condition

    Sorry I didn't explain my query very well: If you select May you get the drop down below:

    30-Apr-16 06-May-16 30-Apr-16 To 06-May-16 Apr
    07-May-16 13-May-16 07-May-16 To 13-May-16 May
    14-May-16 20-May-16 14-May-16 To 20-May-16 May
    21-May-16 27-May-16 21-May-16 To 27-May-16 May
    28-May-16 03-Jun-16 28-May-16 To 03-Jun-16 May

    my understanding is the dropdown should start with 07-May entry not the last entry of the previous month.

    John

    Re "Clearing" the dropdown on new selection: Like you I (vaguely) recall seeing answer - I'll have a trawl and see if I can find something.

  20. #20
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,363

    Re: Data Validation Listing Based on Certain Condition


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

    Re: Data Validation Listing Based on Certain Condition

    John,

    Thanks for that. I suspected it would include a macro.

    Dave

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

    Re: Data Validation Listing Based on Certain Condition

    Quote Originally Posted by JohnTopley View Post

    30-Apr-16 06-May-16 30-Apr-16 To 06-May-16 Apr
    07-May-16 13-May-16 07-May-16 To 13-May-16 May
    14-May-16 20-May-16 14-May-16 To 20-May-16 May
    21-May-16 27-May-16 21-May-16 To 27-May-16 May
    28-May-16 03-Jun-16 28-May-16 To 03-Jun-16 May

    my understanding is the dropdown should start with 07-May entry not the last entry of the previous month.
    Ah. I hadn't read your previous post.

    Yes. I reasoned that since those weeks in May also included the previous / next month there was no harm. My focus was on the weeks.

    I guess to do otherwise would require a rework of the formulas I proposed in E2:P9.

  23. #23
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,363

    Re: Data Validation Listing Based on Certain Condition

    ... see what the OP says!

  24. #24
    Registered User
    Join Date
    12-13-2010
    Location
    India
    MS-Off Ver
    Office 365
    Posts
    18

    Re: Data Validation Listing Based on Certain Condition

    Thanks a Lot FlameRetired... It worked like a Charm...

    Quote Originally Posted by FlameRetired View Post
    Another formula approach.

    In Weeks sheet month headers are in E1:P1.

    Then this array-entered formula in E2 filled down and across to P9 or until you get all blanks under each month.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    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.

    Then redefine the Data validation formula for B2 in the Data sheet as
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    It is important to make sure the $A2 reference in the formula is set relative to row.

    Then redefine Data validation for A2 to
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Fill the drop downs in A2 and B2 down as needed.

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

    Re: Data Validation Listing Based on Certain Condition

    You're welcome. Glad to help, and thanks for the rep.

+ 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. Listing values if condition is met
    By Edfutkina in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 12-10-2015, 05:02 PM
  2. Replies: 0
    Last Post: 10-14-2014, 08:39 AM
  3. [SOLVED] Data validation based on condition
    By Pavan.Sada.PS in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-17-2013, 09:56 AM
  4. IF THEN condition with data validation
    By Dang-er in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-15-2013, 10:24 AM
  5. 6 level dependent listing for data validation to another sheet in excel
    By Ennesai in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-19-2013, 05:03 AM
  6. Data Validation with condition
    By Jaai001 in forum Excel General
    Replies: 6
    Last Post: 06-04-2011, 12:21 AM
  7. Index/match with Data Validation Listing
    By rise206 in forum Excel General
    Replies: 7
    Last Post: 12-30-2010, 12:36 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