Function ImportFromExcel()
Dim fs, f, s
Dim ExcelFileName As String
Dim PathToExcelFiles As String
Set fs = CreateObject("Scripting.FileSystemObject")
PathToExcelFiles = MyLocation
ExcelFileName = Dir(PathToExcelFiles, vbDirectory)
Do While ExcelFileName <> ""
If ExcelFileName <> "." And ExcelFileName <> ".." And Right(ExcelFileName, 3) = "XLS" Then
Set f = fs.GetFile(PathToExcelFiles + ExcelFileName)
s = f.DateLastModified
DoCmd.TransferSpreadsheet acLink, 9, ExcelFileName, PathToExcelFiles + ExcelFileName, True
End If
ExcelFileName = Dir
Loop
End Function
That code works, however since the Excel file I'm looking at has up to 3-4 different worksheets it is causing errors. The worksheet name is Details, how can I pull data from that one specifically? Any ideas? Thanks
Dim fs, f, s
Dim ExcelFileName As String
Dim PathToExcelFiles As String
Set fs = CreateObject("Scripting.FileSystemObject")
PathToExcelFiles = MyLocation
ExcelFileName = Dir(PathToExcelFiles, vbDirectory)
Do While ExcelFileName <> ""
If ExcelFileName <> "." And ExcelFileName <> ".." And Right(ExcelFileName, 3) = "XLS" Then
Set f = fs.GetFile(PathToExcelFiles + ExcelFileName)
s = f.DateLastModified
DoCmd.TransferSpreadsheet acLink, 9, ExcelFileName, PathToExcelFiles + ExcelFileName, True
End If
ExcelFileName = Dir
Loop
End Function
That code works, however since the Excel file I'm looking at has up to 3-4 different worksheets it is causing errors. The worksheet name is Details, how can I pull data from that one specifically? Any ideas? Thanks