Forum Discussion
bullk777
Nov 26, 2018Copper Contributor
Excel Macros
I am trying to import a text file named 2017_recent.txt using macros into a workbook that already has data in it. The issue that I am facing is that this macros has to work for 2018_recent.txt, 2019_recent.txt, and so on for as many years after that. How do I position my macro that imports all of this data and is not just importing 2017 specifically, so that it can adjust to the next year?
1 Reply
- erol sinan zorluIron Contributor
you can get the year of a date within macro and unite it with the rest of the text file name to get its complete name for example:
dim TxtFileName as string
TxtFilneName=Year(now()) &"_recent.txt"