Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Mar 2008
    Posts
    98
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using SQL to query Excel worksheet from within the same workbook

    Does anybody have any examples of using SQL select statements to query data in and Excel spreasheet. I'm looking for examples that show how to do this from within the same workbook. I'm also having trouble figuring out how to get the group by option to work. I don't have a working sheet, just looking for examples of how I could do this. I'm fairly sure I need to use the Micorsoft ADO reference to do this, but again. I'm just looking for examples showing how to do this and how I can group by specific columns. Thanks! (Using Excel 2003, Win XP)

  2. #2
    3 Star Lounger
    Join Date
    Apr 2001
    Location
    Levin, Manawatu-Wanganui, New Zealand
    Posts
    324
    Thanks
    9
    Thanked 28 Times in 26 Posts
    Hi
    You need to supply a bit more detail. There are various options within a workbook.
    Examples
    Advanced filtering that enables you to specify criteria and output regions.
    The subtotal functionality
    Functions like dsum() and others

    And then there are pivot tables. Very powerful reporting tools. Need to be careful with list structure though.
    You may well be asking about sledge hammers to crack nuts.
    Good luck.
    G
    Last edited by geofrichardson; 2011-03-23 at 16:14.

  3. #3
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts
    There are, according to MS, memory leak issues with using ADO to query an open workbook, so you may have problems if you want to run multiple queries. Can you give an example of the sort of query you want to run?
    Regards,
    Rory

    Microsoft MVP - Excel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •