+ Reply to Thread
Results 1 to 6 of 6

Split File Name Into N Parts via Delimiter

  1. #1
    Registered User
    Join Date
    09-08-2017
    Location
    Houston, Texas
    MS-Off Ver
    2010, 2016
    Posts
    34

    Split File Name Into N Parts via Delimiter

    Good afternoon All!

    I am working on a macro that looks at a SharePoint site for files in a folder. The idea is to retrieve the last created date for each file category within a certain naming convention. I'd like to split the file name into two parts based on the 3rd delimiter. Create the dictionary and eventually loop through all the file names to see which ones inside the folder are the last created date.

    Here are my steps I'm trying to create within this macro

    1. Replace format with switch to know which folder to look into [DONE]
    2. Find active workbook's path [DONE]
    3. Map to temporary drive [DONE]
    4. Loop through all files and return latest created date per category
    5. Open last created date and copy worksheets("Summary") and paste into this workbook under new name by second delimiter, ie, MS or Compensation

    Example files for step 4 looks like this:
    Z:\2019_January
    GM1_PL1_Compensation_January_2019_01.xlsb
    GM1_PL1_Compensation_January_2019_02.xlsb
    NAL_WL_MS_January_2019_01.xlsb
    NAL_WL_MS_January_2019_02.xlsb

    Example harvest would look like this:
    GM1_PL1_Compensation
    NAL_WL_MS

    And finally, getting the latest created by date for each category:
    GM1_PL1_Compensation_January_2019_01.xlsb
    GM1_PL1_Compensation_January_2019_02.xlsb [LATEST FILE]
    NAL_WL_MS_January_2019_01.xlsb
    NAL_WL_MS_January_2019_02.xlsb [LATEST FILE]

    Here's my current code so far:
    Please Login or Register  to view this content.
    Help would be greatly appreciated!

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Split File Name Into N Parts via Delimiter

    Hi, don't use split when you're looking inside the filename
    in this part
    Please Login or Register  to view this content.
    Try something like this:

    Please Login or Register  to view this content.
    Another way is to get last date modified attribute of a file
    Hope this helps a little
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Registered User
    Join Date
    09-08-2017
    Location
    Houston, Texas
    MS-Off Ver
    2010, 2016
    Posts
    34

    Re: Split File Name Into N Parts via Delimiter

    Hi @Keebellah!

    Thanks for looking into this for me! I'll definitely try your method. If I wanted to adjust the code to return the left split for everything before 'January' how would I achieve that?

    I've been thinking and working on a different version and this is what I have currently that gets me really close to what I need:

    Please Login or Register  to view this content.
    I was having issues using the JOIN function but I thought about just joining them manually

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Split File Name Into N Parts via Delimiter

    Very simple everything before the month is just the left of the text, p1
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-08-2017
    Location
    Houston, Texas
    MS-Off Ver
    2010, 2016
    Posts
    34

    Re: Split File Name Into N Parts via Delimiter

    Thanks for the direction Keebellah!

    I ended up using your method instead since it looks cleaner and added a check for latest date. Here's the working code if anyone else is looking for something similar:

    Please Login or Register  to view this content.
    PS. I can't find the option to harvest the Author's name of the file that was created. Is it possible?

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Split File Name Into N Parts via Delimiter

    You should try and use Google

    For example here's one link that popped up
    https://stackoverflow.com/questions/...ile-attributes
    Another one
    https://docs.microsoft.com/en-us/off...butes-property

+ 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] Split Text with Varying Delimiter
    By richardking in forum Excel General
    Replies: 15
    Last Post: 08-06-2018, 09:55 PM
  2. Split File Name Into 3 Parts
    By bobbyrabbit in forum Excel General
    Replies: 10
    Last Post: 01-17-2017, 11:41 AM
  3. How to split a column at first delimiter only
    By Jonathan78 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-07-2016, 08:32 AM
  4. Split Text using numbers as Delimiter.
    By ksalsaadi in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-26-2012, 12:42 AM
  5. Split function VBA, space delimiter
    By mkvassh in forum Excel General
    Replies: 3
    Last Post: 10-25-2011, 12:19 PM
  6. Split Cell by Delimiter, Move to New Row...
    By jpfulton in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-16-2008, 03:43 AM
  7. Split Cell by Delimiter, Move to New Row...
    By jpfulton in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 09-08-2008, 03:53 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