I also wanted to post the code that is associated with my problem. The first set reformats the data into the 3 column format I mentioned earlier and then the second is supposed to import all the reformatted excel files into a table.
Private Sub cmd_process_xls_Click()
On Error GoTo Err_cmd_process_xls_Click
' Switch off all the WARNING msgs.
DoCmd.SetWarnings False
Dim strXlsFileName As String
Dim XlsPath As String
Dim WBname As String
Dim Trimname As String
Dim Firstthree As String
Dim UFirstthree As String
Dim TestBook As Workbook
Dim TestSheet As Worksheet
Dim finalrow As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer
MsgBox "Please verify that all the file names begin with the names of the respective sites."
MsgBox "You are going to process the XLS files. This command will delete the non-data columns and rows and will add Site Names to respective files."
XlsPath = xls_file_path.Value
strXlsFileName = Dir(XlsPath & "*.xlsx")
Do While strXlsFileName <> ""
WBname = strXlsFileName
Trimname = LTrim(WBname)
Firstthree = Left(Trimname, 3)
UFirstthree = UCase(Firstthree)
If (StrComp(UFirstthree, "WHI", vbTextCompare) = 0) Then
UFirstthree = "WHT"
End If
If (StrComp(UFirstthree, "BOW", vbTextCompare) = 0) Then
UFirstthree = "BOW"
End If
If (StrComp(UFirstthree, "CON", vbTextCompare) = 0) Then
UFirstthree = "CON"
End If
If (StrComp(UFirstthree, "HUN", vbTextCompare) = 0) Then
UFirstthree = "HUN"
End If
If (StrComp(UFirstthree, "WOL", vbTextCompare) = 0) Then
UFirstthree = "WOL"
End If
If (StrComp(UFirstthree, "DAV", vbTextCompare) = 0) Then
UFirstthree = "DAV"
End If
Set TestBook = Workbooks.Open(XlsPath & strXlsFileName)
Set TestSheet = TestBook.Worksheets(1)
' Delete First Row in the XLS
Cells(1, 1).EntireRow.Delete
' Last 2 columns in XLS
For k = 1 To 2
Cells(1, 3).EntireColumn.Delete
Next k
finalrow = TestSheet.Range("A65000").End(xlUp).Row
For i = 1 To finalrow
TestSheet.Cells(i, 3) = UFirstthree
Next i
TestBook.Application.DisplayAlerts = False
TestBook.Save
TestBook.Application.Quit
strXlsFileName = Dir()
Loop
MsgBox "Data processing successful."
' Switch on the WARNING msgs.
DoCmd.SetWarnings True
Exit_cmd_process_xls_Click:
Exit Sub
Err_cmd_process_xls_Click:
MsgBox Err.Description
Resume Exit_cmd_process_xls_Click
End Sub
Private Sub Cmd_Upload_Data_Click()
On Error GoTo Err_Cmd_Upload_Data_Click
' Switch off all the WARNING msgs.
DoCmd.SetWarnings True
Dim strFileName As String
Dim cstrPath As String
DoCmd.OpenQuery "Query_del_temp_load_tab"
MsgBox "Temp Table Deleted"
cstrPath = txt_box_file_path.Value
'MsgBox " File Path " & cstrPath
strFileName = Dir(cstrPath & "*.xlsx")
MsgBox "Excel Name" & strFileName
Do While strFileName <> ""
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12, "tblTempLoadXls", txt_box_file_path & strFileName
strFileName = Dir()
Loop
MsgBox "Data upload Successful."
' Switch on the WARNING msgs.
DoCmd.SetWarnings True
Exit_Cmd_Upload_Data_Click:
Exit Sub
Err_Cmd_Upload_Data_Click:
MsgBox Err.Description
Resume Exit_Cmd_Upload_Data_Click
End Sub