I have some VBA code that exports SAP data to a .XLSX file, then imports this file into excel. After the file is imported, I have code that performs many other actions (eg p
I have tried to do what I explained in the comments. It isn't very neat and I wasn't able to test. I only changed a couple of lines to tidy a couple of things up, I dont think that line is needed in the Insert .xlsx from file data section thought. Let me know how you go.
Sub OriginalSub()
'Opens SAP connection
[snip as no change]
'Closes SAP connection
[snip as no change]
Call ImportData()
Kill "C:\Users\" & Environ("Username") & "\Downloads\SAP_export.XLSX"
End Sub
Sub ImportData()
'Clear table from SMS Input
ThisWorkbook.Worksheets("SMS Input").Cells.ClearContents
'Insert .xlsx file data
ThisWorkbook.Worksheets("SMS Input").Range("A6").Select
[snip as no changes from here by me]
Workbooks("SAP_export.XLSX").Close savechanges:=False
End Sub