I am using the following code to copy/paste.
The problem is, the downloads folder must be emptied before each download because each successive download adds a (#) to the filename. So, DataGridExport.xlsx becomes DataGridExport(1).xlsx then (2) and so on. Is there a way to reference the most recent DataGridExport.xlsx ignoring the (#)?
VBA Code:
Sub Copynotice()
Dim wb1 As Workbook, wb2 As Workbook
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Set wb1 = ThisWorkbook
Set wb2 = Workbooks.Open("D:\Downloads\DataGridExport.xlsx")
wb2.Sheets("Report1").Range("E2:E120").Copy
wb1.Sheets("Notice").Range("D3").PasteSpecial Paste:=xlPasteValues
wb2.Close
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
The problem is, the downloads folder must be emptied before each download because each successive download adds a (#) to the filename. So, DataGridExport.xlsx becomes DataGridExport(1).xlsx then (2) and so on. Is there a way to reference the most recent DataGridExport.xlsx ignoring the (#)?