I have a project to create VBA to find and open all CSV files in a folder that is named the current month. I found some stuff online that seemed close but not quite. They will eventually be converted to XLSX files and parsed. That part I have. The macro that converts, parses and saves will be housed in a different file along the same path but not as "deep".
So on my Desktop is a folder name "CSV find test". Inside are two folders "Feburary" and "March". I need it to open all csv files in the most recent month. I have the rest of the syntax. . . . .
I wouldn't imagine that it would take a huge amount of syntax. Thanks for any direction.
Sub OpenFile()
FileMonth = Month(Date)
FileDate = Format(Date, "mmmm")
FilePath = "C:\Users\Me\Desktop\CSV find convert tests\" & FileMonth & "\" & FileDate & ".xls"
Workbooks.Open Filename:="FilePath" <- - - - error happens here.
End Sub
FilePathis a variable, not a string. Remove the double-quotes.FileMonth = Format(Date, "mmmm")to get the full month name. 2. UseDebug.Print FilePathbefore you try to open the CSV and look in hte VBE's Immediate window to make sure it is correct. 3. As above.