cordy_star
New member
- Local time
- Today, 02:44
- Joined
- Jul 2, 2013
- Messages
- 1
Hi All,
I have a code that allows the user to select the file that they want to import, however it automatically imports the first worksheet into a specific table. Is it possible to change the code to make it import the first worksheet (or with a specific name) into one table and another worksheet into another table?
Thanks in advance
I have a code that allows the user to select the file that they want to import, however it automatically imports the first worksheet into a specific table. Is it possible to change the code to make it import the first worksheet (or with a specific name) into one table and another worksheet into another table?
Code:
Dim dlg As FileDialog
Set dlg = Application.FileDialog(msoFileDialogFilePicker)
With dlg
.Title = "Select the Excel file to import"
.AllowMultiSelect = False
.Filters.Clear
.Filters.Add "Excel Files", "*.xls", 1
.Filters.Add "All Files", "*.*", 2
If .Show = -1 Then
strfilename = .SelectedItems(1)
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, "TABLE NAME", strfilename, True
Else
Exit Sub
End If
End With
Thanks in advance