Hi
Try this.
1) Access database c:\temp\test3.mdb
2) Table: access_table2
3) The table has 2 fields COL_1 and COL_2
4) Range A1:A3 has the Product IDs and these would be found in COL_1 of the database.
The code below will loop through the items in column A, and bring back the result from COL_2 for the match.
Sub bbb()
Set cn = CreateObject("adodb.connection")
Set rs = CreateObject("adodb.recordset")
cn.Open "provider=microsoft.jet.oledb.4.0;data source = c:\temp\test3.mdb"
For Each ce In Range("A1:A3")
rs.Open "select COL_2 from access_table2 where COL_1 = " & ce.Value, activeconnection:=cn
ce.Offset(0, 1).Value = rs(0)
rs.Close
Next ce
Set rs = Nothing
Set cmd = Nothing
cn.Close
Set cn = Nothing
End Sub
HTH
rylo
Bookmarks