Import specific columns from Excel

  • Thread starter Thread starter Rafi
  • Start date Start date
R

Rafi

I need to import specific columns (A through G) from Excel; however, the
input files (excel) Does not have a constant number of columns. I only need
the first 8 columns. The Excel file has a header row and the column names are
known. Alternatively, I can name the 8 columns that need to be imported.

Thanks for your help

I have tried the following VBA code which resulted in an error: Run-Time
error 3170 - Could Not find Installable ISAM however, to the best of my
knowledge, the reference is in the registry.

Function DHL_Import()
Dim db As DAO.Database
Dim stSQL As String
stSQL = "Insert Into TblRecords" _
& " Select F1 as Name, F2 as [Address 1], F3 as [Address 2], f4 as City," _
& " F5 as State, F6 as [Postal Code], F7 as [Postal Code Plus Four], F8 as
Account" _
& " From [XLS;HDR=Yes;Database=C:\Test\].myImport.xls"
Set db = CurrentDb()
CurrentDb.Execute stSQL

End Function
 
Rafi

Rather than importing, is there a way you could use a query against a linked
table?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Back
Top