I need to insert data from an xls file from the Internet into the current open workbook. The problem is that if I run this macro several times, it always creates a new sheet. Ideally, I would like to delete the old content and replace it with new content on the same sheet. Maybe? Here is my code
Sub downloadData()
Dim wkbMyWorkbook As Workbook
Dim wkbWebWorkbook As Workbook
Dim wksWebWorkSheet As Worksheet
Dim currentDate As Date
Set wkbMyWorkbook = ActiveWorkbook
currentDate = Date
Workbooks.Open ("https://www.somewebpage.com/file.xls")
Set wkbWebWorkbook = ActiveWorkbook
Set wksWebWorkSheet = ActiveSheet
wksWebWorkSheet.Copy After:=wkbMyWorkbook.Sheets(Sheets.Count)
wkbMyWorkbook.Activate
wkbWebWorkbook.Close
End Sub
joe32 source
share