+ Reply to Thread
Results 1 to 2 of 2

Filter 1d array to only return strings with older datestamps

  1. #1
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Filter 1d array to only return strings with older datestamps

    This is going to be tricky to explain. Here goes:

    INPUT

    Suppose I have a folder containing several files. All files have datestamps. Thankfully all datestamps are in the format yyyymmdd.

    I have read the contents of this folder into a 1 dimensional array which lists all of the filenames (File name only. Does not include the folder path. e.g. "Book1 20191204.xlsx" )


    DESIRED OUTPUT

    I want a function that will return a 1d array which "filters" the input so that it will list any outdated versions of files. 'Outdated' is determined from filename string pattern and datestamps. See example below.
    1. aaa 20191204 = REMOVE. only 1x filename with this pattern so no older version
    2. bbbbb 20191125 = KEEP. There is more than one filename with this pattern and this is NOT the latest datestamp for that pattern
    3. bbbbb 20191129 = KEEP. There is more than one filename with this pattern and this is NOT the latest datestamp for that pattern
    4. bbbbb 20191201 = REMOVE. There is more than one filename with this pattern and this is the latest datestamp for that pattern
    5. aaaaanother_example 20191202 = REMOVE. only 1x filename with this pattern so no older version


    I've tried writing this myself but I made a mess of it so I figure uploading this code wouldn't help, only hinder.

    In case anyone asks - File extensions. Yes the input array does include file extensions in the file names. I left the extensions out of the example to keep it simpler. Currently files that share the same pattern share the same file extension (In the unlikely event that the file extension is ever different, I would still treat that file as being part of the same group if it shared the same filename pattern - other than the datestamp and extension)


    (OPTIONAL) INTENDED USE
    If I can identify all of the outdated versions of files in a folder (and ONLY the outdated versions) then I can write a macro which will use this array to move these files into an archival folder. (Or batch delete the outdated versions if that would be preferred)
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

  2. #2
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: Filter 1d array to only return strings with older datestamps

    Solved my problem.

    Please Login or Register  to view this content.

+ 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] Array of lookups returning multiple strings if last two strings are empty
    By chriskay in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-14-2019, 07:35 AM
  2. Match different long strings with an array of short, summarizing strings
    By FKemps in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-24-2015, 12:55 AM
  3. AdvancedFilter to filter cells that doesnt contain array of strings
    By swapnaoe in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-15-2014, 02:24 PM
  4. [SOLVED] Return the Index of an array BUT with an IF condition (or other filter...), Thanks!
    By bbernzy in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-15-2013, 02:20 PM
  5. Replies: 1
    Last Post: 08-13-2013, 08:32 AM
  6. Replies: 9
    Last Post: 12-21-2012, 04:18 AM
  7. Replies: 1
    Last Post: 03-02-2006, 05:00 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