Import from Excel - Empty records problem

  • Thread starter Thread starter MichaelK
  • Start date Start date
M

MichaelK

Hi gurus.

When I import the data from the spreadsheet it's picking up all records to
the end
of the sheet. So I get a huge table and have to clean it after.
I know that can specify the range, but this is a part of the process and
number of
records is changing from file to file.
What is the best way to prevent it if there is one?

Thanks,
Michael
 
If I get the chance I will copy pate the data to a New Spreadsheet in a
rectangular range.
Then that sheet can be imported easily.

Else use named ranges for the import.

Public Sub ImportSpreadsheet(strTable As String, strFileName As String, _
strWorkSheet As String, strRange As String)
'Purpose: to import a specific sheet and range of a workbook
'Usage: ImportSpreadsheet
"tblExcel","c:\temp\Book1.xls","Sheet1","C5:D7"
'True in the options means the top row are field headers
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, _
strTable, strFileName, True, strWorkSheet & "!" & strRange
End Sub
 
Back
Top