Hi!
I have a macro (that works) in alla other aspects than the opening of the textfile that contains the data I'm to use.
The files that should be opened (by a loop?) is updated monthly and named in sequential order.
There are however some characteristics that each file have that allows me to tell them apart.
Example: ANMPF01xxx, ANMPF02xxx and so on; where xxx is the number that's updated every month.
The code below is how I did it before the filenames started changing. I hade the predefined names in cells A10-A20.
How do I get in a variable that looks at file dates and then chooses the latest for all the different types?
I have a macro (that works) in alla other aspects than the opening of the textfile that contains the data I'm to use.
The files that should be opened (by a loop?) is updated monthly and named in sequential order.
There are however some characteristics that each file have that allows me to tell them apart.
Example: ANMPF01xxx, ANMPF02xxx and so on; where xxx is the number that's updated every month.
The code below is how I did it before the filenames started changing. I hade the predefined names in cells A10-A20.
How do I get in a variable that looks at file dates and then chooses the latest for all the different types?
Code:
arr = Sheets("Blad1").Range("A10:A20")
For f = LBound(arr, 1) To UBound(arr, 1)
If Len(arr(f, 1)) > 0 Then
MsgBox arr(f, 1)
File = arr(f, 1)
Workbooks.OpenText FileName:=File, origin:=xlWindows, DataType:=xlDelimited, Semicolon:=True, Tab:=False, Space:=False, Other:=False