+ Reply to Thread
Results 1 to 8 of 8

Ideifying Latest File using string name...

  1. #1
    Registered User
    Join Date
    11-24-2012
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2010
    Posts
    7

    Ideifying Latest File using string name...

    Hi,
    Hoping someone can help me, I'm wanting to write a VBA Macro that identifies the latest filename based on FILENAME, and the lsuffix of that filename... so, in the example below, the answers would:

    Q001035 - Peter G - 0002.pdf, and the suffix would be 0002

    I am not wanting to obtain the latest filename based on modified date. Can anyone please help me. Peter



    Q001035 - Peter G - 0001.pdf
    Q001035 - Peter G - 0002.pdf

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

    Re: Ideifying Latest File using string name...

    Well, if you don't mind an array formula: =MAX(1*MID($A$3:$A$5,FIND("-",$A$3:$A$5,FIND("-",$A$3:$A$5)+1)+1,LEN($A$3:$A$5)-FIND("-",$A$3:$A$5,FIND("-",$A$3:$A$5)+1)-4))

    Where A3:A5 contains the list of file names assuming they are all *** - *** - nnnn.pdf in format.

    Attached is a file with the helper columns that helped me get to this formula.
    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
    Registered User
    Join Date
    11-24-2012
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Ideifying Latest File using string name...

    Hi dflak,

    Much appreciated for this... Can this be written in VBA code, and then let it loop to ensure it goes for all files?

    Peter

  4. #4
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,028

    Re: Ideifying Latest File using string name...

    Hi, peter
    Try this, assuming the list in column A, the result will be in C & D.
    First, you have to sort ascending column A then run macro.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    11-24-2012
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Ideifying Latest File using string name...

    Akuini,
    Thanks for your help... I think I have not conveyed the right message to you and this is my fault... these files are all in the same directory and sit as ".pdf". Can the macro be re-written to search in a directory, and then look for the oldest file based on filename.

    Peter

  6. #6
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,028

    Re: Ideifying Latest File using string name...

    Ok, try this (Assuming no pdf files with name shorter then 9 character in the directory)
    Open a new sheet
    Run the macro
    Select the folder

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    11-24-2012
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Ideifying Latest File using string name...

    Akuini

    Your help is much appreciated.

    Peter

  8. #8
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,028

    Re: Ideifying Latest File using string name...

    You're welcome Peter & thanks for replying.

+ 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] Macro to get the latest file (excel file) in the folder
    By vigneshwaran in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 04-06-2022, 05:36 AM
  2. [SOLVED] List the Name of Latest Modified File by File Type
    By Saarang84 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-22-2015, 12:14 PM
  3. Replies: 9
    Last Post: 11-28-2013, 05:20 PM
  4. Batch file & macro to copy the latest file from a folder
    By paidlukkha in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-19-2013, 03:05 PM
  5. Macro to get the latest file (excel file) from sharepoint sites
    By vigneshwaran in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-13-2012, 09:45 AM
  6. Opening latest version of file and then doing vlookup in that file
    By Dan.carpe@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 12-11-2012, 12:43 PM
  7. Open the latest file to copy and paste data in another file
    By mmf in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-07-2008, 10:41 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