+ Reply to Thread
Results 1 to 15 of 15

Return oldest date in range using asterisk as criteria

Hybrid View

  1. #1
    Registered User
    Join Date
    06-02-2017
    Location
    Newbury
    MS-Off Ver
    2010
    Posts
    50

    Return oldest date in range using asterisk as criteria

    I'm having trouble with my formula in Sheet1!C:C which I believe is due to the fact that I'm using an asterisk as part of the search criteria. I previously used specific criteria e.g. "Kitchen" however due to multiple departments falling under the parent departments (detailed on Sheet3), I need the formula to look for any data beginning with a K. This method worked in Sheet1!B:B using a COUNTIF function, however it doesn't seem to work in my array.
    Attached Files Attached Files

  2. #2
    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
    30,681

    Re: Return oldest date in range using asterisk as criteria

    Try

    =IF(B2=0,"-",MIN(IF(LEFT(Sheet2!$A:$A)=LEFT(A2),Sheet2!$B:$B)))

    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

    then copy down

  3. #3
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Return oldest date in range using asterisk as criteria

    You're right. You cannot use a wildcard character like that.

    Try this instead:

    C2 =IF(B2=0,"-",MIN(IF(LEFT(Sheet2!$A$1:$A$100)="K",Sheet2!$B$1:$B$100))) Ctrl Shift Enter

    Also notice that I changed the whole column references into a smaller range. You do not want to use whole column references in an array formula.

  4. #4
    Registered User
    Join Date
    06-02-2017
    Location
    Newbury
    MS-Off Ver
    2010
    Posts
    50

    Re: Return oldest date in range using asterisk as criteria

    Thanks for this, I'll give this a shot as well as the suggestion from JohnTopley.

    I've been told on this forum before not to use whole column references in an array, can I ask why? In the actual spreadsheet I'm using this in, I'm using the whole column and it's working. The problem with changing to a smaller range is that it's a monthly report and the number of entries can vary massively each month. Would it work if I did a range of B1:B10000? Or is that too large?

  5. #5
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Return oldest date in range using asterisk as criteria

    Here's another alternative assuming that your data is in chronological order like in your sample:

    C2 =IFERROR(VLOOKUP(LEFT(A2)&"*",Sheet2!A:B,2,0),"-")

    You can drag this down.

  6. #6
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Return oldest date in range using asterisk as criteria

    Your version of Excel has 1,048,576 rows. If you use whole column references in an array formula, the formula has to calculate through over 1 million rows.

    Although this will usually work, it can slow the workbook down tremendously.

    Using a range of B$1:B$10000 would be much better. 10,000 rows is less than 1% of the entire column.
    Alternatively, you can convert your data into a table and refer to the table column, which will expand and contract automatically as you add or remove data.

  7. #7
    Registered User
    Join Date
    06-02-2017
    Location
    Newbury
    MS-Off Ver
    2010
    Posts
    50

    Re: Return oldest date in range using asterisk as criteria

    That's beyond my capabilities. I'll go with the 1:10000 option. Thanks for explanation.

  8. #8
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Return oldest date in range using asterisk as criteria

    Happy to help. Thanks for the rep!

  9. #9
    Registered User
    Join Date
    06-02-2017
    Location
    Newbury
    MS-Off Ver
    2010
    Posts
    50

    Re: Return oldest date in range using asterisk as criteria

    I shouldn't have marked this as solved so soon. My actual spreadsheet is more complex than this example. Please could you advise how I would add additional search criteria into the same formula? E.g. If parent department "Kitchen" had multiple child departments, one beginning with K as shown in the example, one beginning with X and one beginning with Z. If needed, I can amend the spreadsheet to show what I mean.

  10. #10
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Return oldest date in range using asterisk as criteria

    Quote Originally Posted by glomb175 View Post
    If needed, I can amend the spreadsheet to show what I mean.
    If you share a more representative sample of your data along with the desired results based on that sample, we'll take a look.

  11. #11
    Registered User
    Join Date
    06-02-2017
    Location
    Newbury
    MS-Off Ver
    2010
    Posts
    50

    Re: Return oldest date in range using asterisk as criteria

    Thank you, I've updated the attached so that the Kitchen department contains multiple sub departments each beginning with a different letter.
    Attached Files Attached Files

  12. #12
    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
    30,681

    Re: Return oldest date in range using asterisk as criteria

    How do you link Kitchen (parent) to Children ??????

    EDIT: did not see Sheet3!!!!
    Last edited by JohnTopley; 06-01-2018 at 03:29 PM.

  13. #13
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Return oldest date in range using asterisk as criteria

    Here's one option:

    Sheet2 C2 =INDEX(Sheet3!A:A,MATCH(A2,Sheet3!B:B,0))
    Drag down column C.

    Sheet1 C2 =IF(B2=0,"",MIN(IF(Sheet2!C$2:C$36=A2,Sheet2!B$2:B$36))) Ctrl Shift Enter
    Drag down column C.

  14. #14
    Registered User
    Join Date
    06-02-2017
    Location
    Newbury
    MS-Off Ver
    2010
    Posts
    50

    Re: Return oldest date in range using asterisk as criteria

    Is there another way? Just because in my original spreadsheet there are tens of thousands of individual sub divisions under each department.

    Therefore the index would be enormous.

  15. #15
    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
    30,681

    Re: Return oldest date in range using asterisk as criteria

    Your INDEX is Sheet3 so no change there: it is FIXED and yes, will be enormous !

    In Sheet2 we have to relate back to your INDEX (as per solution offered) so we know the Parent/Child relationship..

+ 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. [SOLVED] Return the oldest date when cell does not contain an *(Asterix)
    By C J W in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-13-2017, 12:25 PM
  2. Return oldest date in range when a file is open
    By mementomori in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-08-2016, 10:17 AM
  3. Return oldest date with some dates excluded
    By Stromming in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-30-2014, 06:32 AM
  4. return oldest date based on call value
    By 288enzo in forum Excel General
    Replies: 8
    Last Post: 02-28-2014, 10:50 PM
  5. [SOLVED] Find Oldest Date for Criteria in different Column
    By mglassco in forum Excel General
    Replies: 12
    Last Post: 04-19-2012, 09:27 PM
  6. Display value based on oldest date and other criteria.
    By Permagrin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-03-2009, 09:48 AM
  7. Getting the oldest date with criteria
    By Sara_Chase in forum Excel General
    Replies: 5
    Last Post: 10-17-2006, 08:11 AM

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