Right so we have a new system here, its a SAP based system but is it terrible (but I dont make these decisions unfortunately). Basically at the moment it doesnt have all the "Steps" that need to be performed in each jobs, hence this Access database which is going to keep track of these "steps" so users can know what point jobs are at etc and update them in SAP.
The "steps" I'm talking about, are all the extra fields that is in tbl_Main that are not in tbl_Import in my screenshots.
So basically each morning the department head will get a xls pull of data from SAP into a xls file. This xls file is then imported (I have covered this in other code in other threads you might have seen), creating the tbl_Import table each morning. The xls data import is the raw data, the only formatting I do to it (as seen in code in my other threads here) is delete some unneeded columns, change the dates into dates that Excel and Access can read (as dates) and change a "X" to a "-1" (for the Yes/No Manifest Status field). Other than that the tbl_Import table is a straight import from the xls file.
Does that answer your question? Actually here is a demo xls: Demo Data.zip
Basically I have a file like this (but much much bigger, around 2k lines), and run this code on it:
Code:
Sub FormattExcel()
SelectFile:
Set f = Application.FileDialog(1)
With f
.AllowMultiSelect = False
.Title = "Please select daily upload from NFE"
.Show
For i = 1 To .SelectedItems.Count
filepath = .SelectedItems(i)
Next i
End With
If filepath = vbNullString Then
Answer = MsgBox("Do you want to select daily upload file again?", vbYesNo, "No Upload File Selected!")
If Answer = vbYes Then
GoTo SelectFile
Else
Exit Sub
End If
Else
End If
Dim objExcel As Excel.Application
Set objExcel = New Excel.Application
With objExcel
.Workbooks.Open filepath
file = Right(filepath, Len(filepath) - InStrRev(filepath, "\"))
.Workbooks(file).Sheets(1).Range("G:H,K:K").Delete
Lastrow = .Workbooks(file).Sheets(1).Range("A" & .Rows.Count).End(xlUp).Row
.Workbooks(file).Sheets(1).Range("F2:F" & Lastrow).NumberFormat = "dd/mm/yyyy"
For Each rgCell In .Workbooks(file).Sheets(1).Range("F2:F" & Lastrow).Cells
DateSplit = Split(Left(rgCell, 10), ".", 3)
rgCell.Value = DateSerial(DateSplit(2), DateSplit(1), DateSplit(0))
Next rgCell
For Each rgCell In .Workbooks(file).Sheets(1).Range("I2:I" & Lastrow).Cells
If rgCell.Value = "X" Then
rgCell.Value = -1
Else
rgCell.Value = 0
End If
Next rgCell
.Application.DisplayAlerts = False
.Workbooks(file).SaveAs "C:\Users\tbaker\Desktop\Merge\FB DB Saves\ImportTemp.xls", 56
.Workbooks("ImportTemp.xls").Close False
.Quit
End With
Set objExcel = Nothing
End Sub
So yeah, delete a few columns, change the dates and change the X's.
You mention comparing variables with VBA using loops, I can do that easily in Excel (Access VBA I'm still new with). But there are thousands of records involved, that loop would take sometime I believe, or at least it would in Excel.