Hi
I'm planning to use this code to import data from an .xlsx file.
But I was wondering if it's possible to save the .xlsx file as an xlsm file first (using VBA), after which I'll select a specific sheet in it....
Is that possible? ie use VBA to save the file as an .xlsm file first, then open that file?
I'm planning to use this code to import data from an .xlsx file.
But I was wondering if it's possible to save the .xlsx file as an xlsm file first (using VBA), after which I'll select a specific sheet in it....
Is that possible? ie use VBA to save the file as an .xlsm file first, then open that file?
VBA Code:
Sub ImportFile()
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 "xlsx files", "*.xlsx"
fd.Filters.Add "Custom Excel Files", "*.xlsx, *.xlsm, *.xls"
fd.AllowMultiSelect = False
fd.InitialFileName = Environ("UserProfile") & "\Downloads"
If fd.Show <> -1 Then
MsgBox "You didn't select a file?"
Exit Sub
End If
'filewaschosen = fd.Show
fd.Execute
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Range("A1:B" & lastrow).Copy
Report.Activate
ACV.Visible = True
ACV.Activate
Range("A1:B" & lastrow).PasteSpecial
End Sub