Setting filenames to incremental variables
Hello!
I have a folder with many files in it with the name format of RD130522 for the file made on may 22 2013.
I have a code that I am using to move certain rows of data from one file to the previous file repetetively.
for setting the file to which I want to move the rows to is there a way to save the file names to multiple variables such
as assigning the 3rd and 4th character (13 in the example) to Y (for year) and 5th and 6th to M for month and 7th and 8th
to D for day. So that I could move the data to filename ("RD" & Y & M & D-1) ? Does anyone know how to do this?
Re: Setting filenames to incremental variables
or is there a way to automatically declare previous file for the file to move it to?
Re: Setting filenames to incremental variables
try like
Code:
filen = "RD130522"
prevfile = Left(filen, 2) & Format(DateSerial(Mid(filen, 3, 2), Mid(filen, 5, 2), Mid(filen, 7, 2) - 1), "yymmdd")
Debug.Print prevfile
change format if required