Solved

sql against a spreadsheet

Posted on 2001-09-17
5
287 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Window placement 17 75
VBA: Add rows to listbox based on criteria 7 74
MS Access Search and Replace Using VBA 6 57
using web browser with BING 40 110
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

920 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

13 Experts available now in Live!

Get 1:1 Help Now