I currently have code that includes the line:
Workbooks.Open Filename:=Company + “.xlsx”,ReadOnly:=True, UpdateLinks:=0
Company is a string that is fed in from a different part of the code.
For many years, that filename string has not changed and my code has worked perfectly. However, the department providing the files is changing their naming convention and the names will change monthly. The first two characters of the file name – the actual company number – will not change. For example, file name that used to be ABCCompany.xlsx could now be 12-ABCCompany_0916_Revised.xlsx one month and 12_ABCCcompany_1016.xlsx the next. There will only be one file for company 12 in the source directory and it will always start with 12. The same for all the other companies. We have no control over what will come after the number.
Is there a way to feed 12* as Company in the variable shown above or some other way to get a wild card in there? I tried 12* without + “.xlsx” and that did not work.
I do not want to either rename the source files every month or rewrite my code to account for the varying names.
Thank you for your suggestions.
Nancy