Solved

sql against a spreadsheet

Posted on 2001-09-17
5
284 Views
Last Modified: 2010-05-02
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

0
Comment
Question by:mmcmillen
5 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 6488062
Are you using VB to open the spreadsheet, or are you using VBA (within Excel, itself) - that is VBA in an Excel macro?
0
 
LVL 3

Accepted Solution

by:
Diveblue earned 100 total points
ID: 6488141
0
 
LVL 12

Expert Comment

by:roverm
ID: 6488158
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;Database=96Sales"
With ActiveSheet.QueryTables.Add(Connection:=connstring, _
        Destination:=Range("B1"), Sql:=sqlstring)
    .Refresh
End With

(example from Excel help)

D'Mzzl!
RoverM
0
 
LVL 2

Author Comment

by:mmcmillen
ID: 6488237
I am opening excel as an excel8 object
0
 
LVL 2

Author Comment

by:mmcmillen
ID: 6488253
Thanks everyone for their time .

0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now