Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I need to load different sets of column names from excel sheet files based on the file name's month/year which is labeled name month year (example: FILEJAN22). The basic set up I have right now is for each file, check if the year is <= 22, if so load these 5 column names, and if not if its 23 AND the month is August through December, then load this other set of 5 column names.
Having trouble figuring out how to get the current file that the loop is using to pull out the month and year of that file in order for it to be checked properly. Any solutions or advice is appreciated.
How are you looping? With Filelist() or wildcard?
-Rob
You can use filename() function inside your table script in combination with functions like left() & right() to extract desired part from file name string.
Regards,
Aditya
I am not using either, I am just using a for each dir in dirlist (*) and then for each file in filelist(*);
Would I be able to pull a file name each time in my for loop with Filelist()? What would be some foundational code for that?
Do you have some example filename() function code I could refer to?
For each fname in FileList('*.xlsx')
if mid('$(fname)', 10, 2) = '22' Then ...
Next