Reputation: 1
I have an online report that when downloaded automatically opens as a *.csv file. I then open another Excel workbook containing various macros and want to copy the entire downloaded sheet (sheet1) over to the my main workbook either as a new sheet or into an existing blank sheet named "DATA".
My problem is referencing the open downloaded sheet as each time it is downloaded the name is different. My preference is to not save the downloaded workbook and then copy as I just delete the file when I am done.
Any help with referencing the downloaded file and activating it would be appreciated.
Upvotes: 0
Views: 181
Reputation: 27478
I've been thinking about Application.RecentFiles
today and wonder if it would work here. The assumption is that the csv is the most recently opened file, i.e., it's at the top of the Home>Recent list:
Sub ActivateMostRecentOpened()
Dim WbName As String
With Application
WbName = Workbooks(.RecentFiles(1).Name, InStrRev(.RecentFiles(1).Name, .PathSeparator) + 1).Activate
End With
End Sub
Upvotes: 0