Solved

sql against a spreadsheet

Posted on 2001-09-17
5
310 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

689 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