I'm looking for a way to import a specific tab into my Access table. Normally I do a TransferSpreadsheet type of code, so this is rather new to me.
I need the user to be able to open the file from any directory - followed by have the program import a specific spreadsheet that can have a semi-variable name.
The spreadsheet that needs to be imported is always " Details". So obviously, right now the file would contain a tab called July Details. So my logic with this bit of code was to find the spreadsheet with LIKE (or *) Detail. I'm not sure if this works however, and I'm not sure how best to transfer this to my Access Table since I'm so used to TransferSpreadsheet. Any help is appreciated!
Dim wb1 As Workbook
Dim wb2 As Workbook
Set wb1 = ActiveWorkbook
ImportFileName = cmdFileDialog("Select File to Import: ")
Set wb2 = Workbooks.Open(FileName:=ImportFileName)
For Each Sheet In wb2.Sheets
If Sheet.Name Like Detail Then
Sheet.Copy After:=wb1.Sheets(wb1.Sheets.Count)
End If
Next Sheet
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, DataTable, ImportFileName, True, DataRange
EDIT: Let me clarify: Once I find the sheet with Details in it, I am not sure how to import it into an Access table like I need. That is my last problem with this.