Hello,
I want to adapt my code below for a new function I need. This code imports sheets with the name 'Result1, Result2, Result3, etc.' for ranges 1 to 11.
I now want to import sheets '3 To ShtCount' , each sheet name will be different.
My issue is that I want this to import from all files in a directory, and each sheet may not always be in each file.
Should I just find each of the sheet names that might occur and hard code them in?
I want to adapt my code below for a new function I need. This code imports sheets with the name 'Result1, Result2, Result3, etc.' for ranges 1 to 11.
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</pre>
I now want to import sheets '3 To ShtCount' , each sheet name will be different.
My issue is that I want this to import from all files in a directory, and each sheet may not always be in each file.
Should I just find each of the sheet names that might occur and hard code them in?