Hi
I have some code which opens a file and imports data from it.
However, once data has been imported from the file that has been opened, I would like to close the file (that the data is imported from).
Does anyone know how to adjust this code so that it closes the iWB file without saving changes to it, please? (The iWB file is the file that data is imported from).
I have some code which opens a file and imports data from it.
However, once data has been imported from the file that has been opened, I would like to close the file (that the data is imported from).
Does anyone know how to adjust this code so that it closes the iWB file without saving changes to it, please? (The iWB file is the file that data is imported from).
VBA Code:
Sub CloseTab1()
Dim fd As FileDialog
Dim filewaschosen As Boolean
Dim Report As Workbook
Dim iWB As Workbook
Set Report = ActiveWorkbook
Set fd = Application.FileDialog(msoFileDialogOpen)
fd.Filters.Clear
fd.Filters.Add "Custom Excel Files", "*.xlsx, *.xlsm, *.xls"
fd.AllowMultiSelect = False
fd.InitialFileName = Environ("UserProfile") & "\Box\"
If fd.Show <> -1 Then
MsgBox "You didn't select a file?"
Exit Sub
End If
fd.Execute
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Range("A2:G" & lastrow).Copy
Report.Activate
ACV.Visible = True
ACV.Activate
Range("A2:G" & lastrow).PasteSpecial
ControlCenter.Activate
Range("J9").Activate
End Sub