I have a macro that needs to open files but the problem is everyday it is in a new folder labeled according to the day. Example today would be C:\\WORK\\122315\\fileexample.xlsx
How I usually open files with dates is by entering the date in cell A1 as a TEXT "122315" then use Date1 = Range("A1").Value in vba. My question is what do I do if the date is not in the file, but in the subfolder?
Date1 = Range("A1").Value
ChDir "C:\WORK\Date1"
Workbooks.Open Filename:= _
"C:\WORK\Date1\fileexample.xlsx"
Workbooks.Open Filename:="C:\WORK\" & Range("A1").Value & "\fileexample.xlsx"
仅供参考,如果您将完整文件路径传递给Open
则不需要使用ChDir
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.