Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sql Query a Excel spreadsheet

Status
Not open for further replies.

ClulessChris

IS-IT--Management
Jan 27, 2003
890
GB
Can anybod give me some pointers on using Sql to search an Excel spreadsheet?
I'm familiar with using DAO / ADO to query a database, but in this instance I'd like to query a spreadsheet from within the same workbook (e.g. Sheet1!A1 = "SELECT 'column C' FROM Sheet2 WHERE 'Column B' = 123").

Is it even worth doing this with VB or are there inbuilt Functions for this action?

Everybody body is somebodys Nutter.
 
Hi Clulesschris

May be you could use the vlookup function in excel

ip
 




Hi,

This can be done without any VBA, using native Excel functionality: Data>Get External Data>New Database Query...

This adds a QueryTable to the sheet that can, subsequently, be Data>Refresh to retunr a fresh recultset.

Skip,

[glasses] [red][/red]
[tongue]
 
Many thanks for you responces.

Everybody body is somebodys Nutter.
 
F.y.i

I used the following connection string :

Set db = Opendatabase(FileName, False, True, "Excel 8.0;HDR=Yes;")

Opens Excel with DAO just fine.

Everybody body is somebodys Nutter.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top