I am comparing sheets in a workbook. The workbook has two sheets named PRE and POST with the same 19 columns in each. The number of rows varies every day but are same for th
Perhaps you can go with 2 adjustments, although their performance impact will be only very small:
' prepare references to worksheets
Dim WorksheetPRE As Worksheet
Dim WorksheetPOST As Worksheet
Set WorksheetPRE = ActiveWorkbook.Worksheets("PRE")
Set WorksheetPOST = ActiveWorkbook.Worksheets("POST")
and then, in your code, replace ActiveWorkbook.Worksheets("PRE")
for WorksheetPRE
etc.
I think no other significant optimizations are possible when you stay in Excel. Remember, Microsoft Excel is primarily a spreadsheet calculator, not a data-table processing tool.
If I really needed to speed-up the comparisons, then I would go with one of these approaches:
link Excel worksheet to Microsoft Access as table and perform the comparison in Access (easiest)
as the above, but instead of linking the table, import it
as the above two, but use Microsoft SQL Server (Express version is free)