Hello,
Originally I used the below code to import sheets from Excel into Access... The sheets were named as follows 'Result 1', 'Result 2' etc ..
Now I want to import a range of sheets (3-15) that have all different types of names. I don't understand how to use a changing variable as the name to import.
Please help
Originally I used the below code to import sheets from Excel into Access... The sheets were named as follows 'Result 1', 'Result 2' etc ..
Now I want to import a range of sheets (3-15) that have all different types of names. I don't understand how to use a changing variable as the name to import.
Please help
Code:
Public Sub Import_Core()
Dim x As Integer
Dim strSheet As String
On Error GoTo Handler:
For x = 1 To 11
strSheet = "Result " & x & "!"
DoCmd.TransferSpreadsheet _
acImport, _
acSpreadsheetTypeExcel8, _
"core", _
"\\msad\root\NA\NY\LIB\fid\FIDSTP\Centralized Reference Data\Clear Exports\core.xls", _
True, _
strSheet
Next x
MsgBox "Core Complete."
Exit Sub
Handler:
MsgBox Err.Description
End Sub