Record a macro of running a query on your database. "Tools";"Macro";"Record New Macro"
Not really important what query you run, it's just to get the wizard to do the heavy lifting of writing the code to connect to a db, run a query, and put the results into a spreadsheet.
Now, edit the macro. The wizard's macro will probably be about 20 lines or so long. You will be looking for a line that says something like:
I added the space-underscore-ampersand line extenders to make it easier to see on this forum. The robot that writes the macro in Excel hasn't heard of pretty-printing; it's one long line.
Here's how you modify it to look in a cell of another worksheet for its criterion:
My query happens to be in SQL Server dialect of SQL, where '%' is the wild-card character. Yours will need to be in the proper dialect for your db, so it may be different in that spot.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.