+ Reply to Thread
Results 1 to 6 of 6

DAO and Multiple Excel Workbooks

  1. #1
    Registered User
    Join Date
    06-12-2008
    Location
    Newbury
    MS-Off Ver
    Office 365 ProPlus
    Posts
    92

    DAO and Multiple Excel Workbooks

    I'm doing some stuff where it's a lot easier to get results using SQL but I'm not sure how to do the following.

    I've got named ranges in two workbooks so if I want to query them I just use

    Please Login or Register  to view this content.
    Which works fine but for some calculations I want to write a SQL statement along the lines of:

    Please Login or Register  to view this content.
    Is this possible?

    I know could just just create a second database object and then copy the data into the same workbook and then create a named range and then use that in my SQL statement was just wondering if there was anyway of having multiple workbooks in the same database.

    Cross posted
    Last edited by chergh; 10-17-2008 at 08:41 AM.

  2. #2
    Forum Contributor Stuie's Avatar
    Join Date
    09-17-2006
    Location
    Suffolk, UK
    MS-Off Ver
    Excel 2003/2007
    Posts
    432
    Hi chergh,

    Can you not make a string variable to get the value from the second workbook like so

    Please Login or Register  to view this content.
    and then change SQL string to this

    Please Login or Register  to view this content.
    see if that would work
    There are only 10 types of people in the world:
    Those who understand binary, and those who don't!

  3. #3
    Registered User
    Join Date
    06-12-2008
    Location
    Newbury
    MS-Off Ver
    Office 365 ProPlus
    Posts
    92
    No that doesn' seem to work. I would think the table (named range) would need to exist within the same database object. Hmmm I might be able to add it as a linked table, time to look at the the help files again.

  4. #4
    Registered User
    Join Date
    06-12-2008
    Location
    Newbury
    MS-Off Ver
    Office 365 ProPlus
    Posts
    92
    Ok I'm now getting a run time error 3251 "Operation is not supported for this
    type of object" with the following code, the error occurs on the last line

    Please Login or Register  to view this content.
    Anyone got any ideas?

  5. #5
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573
    ADO would be better. See GetData at Ron's site. http://www.rondebruin.nl/ado.htm

  6. #6
    Registered User
    Join Date
    06-12-2008
    Location
    Newbury
    MS-Off Ver
    Office 365 ProPlus
    Posts
    92
    I'm not wanting to copy the data across, thats a last resort.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1