mmcmillen
asked on
sql against a spreadsheet
I need to return a recordset from an excel spreadsheet and total certain fields before I upload the data to an AS400 file. I already have the worksheet defined in VB. I need to know if its possible to use sql against the spreadsheet in this way.. Thanks in advance.
God Bless America
God Bless America
Are you using VB to open the spreadsheet, or are you using VBA (within Excel, itself) - that is VBA in an Excel macro?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In Excel you can use the QueryTables.Add method to add data to a sheet:
Dim qt As QueryTable
sqlstring = "select 96Sales.totals from 96Sales where profit < 5"
connstring = _
"ODBC;DSN=96SalesData;UID= Rep21;PWD= NUyHwYQI;D atabase=96 Sales"
With ActiveSheet.QueryTables.Ad d(Connecti on:=connst ring, _
Destination:=Range("B1"), Sql:=sqlstring)
.Refresh
End With
(example from Excel help)
D'Mzzl!
RoverM
Dim qt As QueryTable
sqlstring = "select 96Sales.totals from 96Sales where profit < 5"
connstring = _
"ODBC;DSN=96SalesData;UID=
With ActiveSheet.QueryTables.Ad
Destination:=Range("B1"), Sql:=sqlstring)
.Refresh
End With
(example from Excel help)
D'Mzzl!
RoverM
ASKER
I am opening excel as an excel8 object
ASKER
Thanks everyone for their time .