vba code to query sql db from excel

I have an excel sheet with 2 rows of information. the first row is numbers/id's. I have a sql db with more information for each id. I want to query the db and for each id, to return the rest of the info into excel. So Select where id=value in the cells in the first column. I can conect to the db so that part is working but I can't / do not know how to fit in the where properly. so here is the way i think it has to be. I get the id in cell one, search through the whole datatbase for that id and return the results in the next columns. then i move on cells 2 and so on. any help is appreciated
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I would hesitate about making a function connect to a database because you will be opening and closing connections and causing quite a mess.  I would in a separate spreadsheet connect to the database and pull in a range of records through ODBC (or ado if you don't want to use a hard connection).  Then I would use Vlookup to retrieve the records from the page you just pulled in.  You could hide the page from the end  user, and refresh the data when the workbook is opened.  It would be much quicker that way.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.