hi
so im trying to import an excel sheet into access, i want to be able to select the sheet and range, i have tried various different ways to reference the sheet but i just cannot get it to work.
does anybody have any suggestions please
here is my code so far, the sheet is always in the same location in the workbook, but the name has spaces in it, and im not sure if this is effecting the code,
so the error i get when it runs is
run time error 2498
an expression you entered is the wrong data type for one of the arguments.
ive removed the variable "SheetName" from the argument, and it works, but i dont know how else to reference the sheet name
ive tried "('mf020118 Run In')!A2:h15"
"'mf020118 Run In'!A2:H15"
none of them work
so im trying to import an excel sheet into access, i want to be able to select the sheet and range, i have tried various different ways to reference the sheet but i just cannot get it to work.
does anybody have any suggestions please
Code:
Private Sub btnCreateInServiceIssues_Click()
'On Error GoTo btnCreateInServiceIssues_Click_Err
Dim SheetName As String
Dim TableName As String
' On Error GoTo ErrorHandler
'disable ms access warnings
SheetName = "Sheet(8)!A2:H15"
TableName = "Table_RunIns"
DoCmd.SetWarnings False
DoCmd.RunSQL "DELETE * FROM Table_RunIns"
'load spreadsheet
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, TableName, selectFile(), SheetName, True
're-enable ms access warnings
DoCmd.SetWarnings True
here is my code so far, the sheet is always in the same location in the workbook, but the name has spaces in it, and im not sure if this is effecting the code,
so the error i get when it runs is
run time error 2498
an expression you entered is the wrong data type for one of the arguments.
ive removed the variable "SheetName" from the argument, and it works, but i dont know how else to reference the sheet name
ive tried "('mf020118 Run In')!A2:h15"
"'mf020118 Run In'!A2:H15"
none of them work