CreativeUsername
Board Regular
- Joined
- Mar 11, 2017
- Messages
- 52
Hi,
I'm trying to get VBA to find the current month folder on a given file path then open all ".csv" items in that folder. I had code that die something similar with in a given folder. Now the folder is a variable. If I put "March" in the file path it finds it and opens it obviously. What want to do is swap "March" with a "ThisMonth" variable. but I'm missing something. Several versions haven't worked.
I'm trying to get VBA to find the current month folder on a given file path then open all ".csv" items in that folder. I had code that die something similar with in a given folder. Now the folder is a variable. If I put "March" in the file path it finds it and opens it obviously. What want to do is swap "March" with a "ThisMonth" variable. but I'm missing something. Several versions haven't worked.
Code:
Sub OpenCSVs()
Dim MyFiles As String, ThisMonth As String
ThisMonth = Month(Date,"mmmm")
MyFiles = Dir("C:\Users\ME\Desktop\CSV find convert tests\ThisMonth\*.csv")
Do While MyFiles <> ""
Workbooks.Open "C:\Users\ME\Desktop\CSV find convert tests\ThisMonth\" & MyFiles
'ActiveWorkbook.Close SaveChanges:=True
MyFiles = Dir
Loop
End Sub