Code:
Public Sub Import()
'DoCmd.SetWarnings (WarningsOff)
Set db = CurrentDb() 'Establish a Connection to the Current Database
On Error Resume Next
DoCmd.RunSQL ("DROP TABLE 041913_ARMS_Manual_Review_2") 'Drop Table if exists
DoCmd.RunSQL ("CREATE TABLE [041913_ARMS_Manual_Review_2]") 'Create the loading table
Set tb1 = db.TableDefs("041913_ARMS_Manual_Review_2") 'Create a table definition to add fields to loading table
Set fd = Application.FileDialog(msoFileDialogFilePicker) 'Open file chooser to select file to load into loading table
counter = 0 'Set column counter to zero.
With fd
.Show
For Each vrtSelected In .SelectedItems
Set xlapp = CreateObject("Excel.application")
Set xlWrkBk = GetObject(vrtSelected)
Set xlsht = xlWrkBk.Worksheets(1)
'Loop First Row in Excel File which contains header column names
strcolumns = Array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "AA", "AB", "AC", "AD", "AE", "AF", "AG", "AH", "AI", "AJ", "AK", "AL", "AM", "AN", "AO", "AP", "AQ", "AR", "AS", "AT", "AU", "AV", "AW", "AX", "AY", "AZ", "BA", "BB", "BC", "BD", "BE", "BF", "BG", "BH")
For Each strColumn In strcolumns
counter = counter + 1 'increase the counter to determine the number of columns
Set columnName = xlsht.Cells(1, strColumn)
Set FieldName = tb1.CreateField(columnName, dbText, 200) 'insert text type fields into table def
tb1.Fields.Append FieldName
Next strColumn
'transfers data from excel file and imports it into access table
DoCmd.TransferSpreadsheet acImportDelim, , TableName:="041913_ARMS_Manual_Review_2", FileName:=vrtSelected, HasFieldNames:=True
Next vrtSelected
End With