?
Solved

sql against a spreadsheet

Posted on 2001-09-17
5
Medium Priority
?
315 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 400 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…
Suggested Courses

762 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