I have two worksheets in a workbook that contain a list of IDs, and I need to find a list of IDs that doesn't exist in one.
I'm looking to compare the "Latest" sheet to "Previous" and look for IDs that are in "Latest" that's missing in "Previous"
Here's the code I'm using below... But I'm not getting the result set I'm expecting
Dim wb as workbook, comp_sql as string, comp_rs as new adodb.recordset, new_ws as worksheet
Dim objconn As New ADODB.Connection
Set wb = ThisWorkbook
Set new_ws = wb.Worksheets("New")
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Extended Properties").Value = "Excel 8.0;HDR=Yes;IMEX=1"
comp_sql = "SELECT a.sid, b.sd " & _
"FROM [Latest$] as a LEFT JOIN [Previous$] as b ON a.sid = b.sid " & _
"WHERE b.sid IS NULL "
comp_rs.Open comp_sql, objconn
If comp_rs.State <> 0 Then
If Not (comp_rs.EOF And comp_rs.BOF) Then
new_ws.Cells(1, 1).Value = "sid"
new_ws.Cells(2, 1).CopyFromRecordset comp_rs
Set comp_rs = Nothing