|
-
May 23rd, 2013, 11:51 AM
#1
Thread Starter
Junior Member
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?
-
May 23rd, 2013, 11:52 AM
#2
Thread Starter
Junior Member
Re: Setting filenames to incremental variables
or is there a way to automatically declare previous file for the file to move it to?
-
May 24th, 2013, 05:48 AM
#3
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|