ESmith3187
New Member
- Joined
- Mar 22, 2017
- Messages
- 5
I found the code below but it is not working.
I am trying to find a code that will find a file utilizing where only the first two characters in the file name are know.
This is in Excel 2010. My file names will always be AA_MMM_YYYY.xlsx, BB_MMM_YYYY, CC_MMM_YYYY where the "MMM" changes
each month to the current month.
I found the following code but it is not working. Any insight is appreciated.
I am trying to find a code that will find a file utilizing where only the first two characters in the file name are know.
This is in Excel 2010. My file names will always be AA_MMM_YYYY.xlsx, BB_MMM_YYYY, CC_MMM_YYYY where the "MMM" changes
each month to the current month.
I found the following code but it is not working. Any insight is appreciated.
Code:
Sub OpenFiles()
Dim MyFolder As String
Dim MyFile As String
MyFolder = "C:\Users\JohnDoe\Desktop\2017"
MyFile = Dir(MyFolder & "\*.xlsx")
Do While MyFile <> ""
Workbooks.Open Filename:=MyFolder & "" & MyFile
MyFile = Dir
Loop
End Sub
Last edited by a moderator: