+ Reply to Thread
Results 1 to 5 of 5

getrows trouble

  1. #1
    Registered User
    Join Date
    08-21-2012
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2013
    Posts
    75

    getrows trouble

    So I have the following code:

    Please Login or Register  to view this content.


    I Deleted some random stuff from the above as it doesnt pertain to anything other than finding the correct target range and the path of the files etc but I left everything that has to do with my connection to another file along with where Im running into trouble which I bolded...


    Please Login or Register  to view this content.

    If I substitue in for the bolded part the code above everything works fine... I get multiple results printed out to my spreadsheet... however if I use the original code I only seem to get 1 result to the spreadsheet... Any idea why that is? My goal is to get rid of the spreadsheet part and have a array variable that I can work with later


    Thanks.

  2. #2
    Valued Forum Contributor kasan's Avatar
    Join Date
    07-22-2009
    Location
    Riga, Latvia
    MS-Off Ver
    Excel 2010
    Posts
    680

    Re: getrows trouble

    May be:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-21-2012
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2013
    Posts
    75

    Re: getrows trouble

    hey it works thanks! It grows horizontally which was unexpected easily fixed with transpose


    That will be enough for most of what I need to do, however there is 1 part of my project I havent yet figured out..

    I would need to take that array and use its results to run more queries, then report those answers

    So for instance if I ran Query 1 and it said the results were A , B , C

    I then would need to run a Query on A to see what it breaks down to ... say a,b,c Then B for d,e,f and C for g,h,i

    Then instead of listing to my spreadsheet A,B and C i would instead see a,b,c,d,e,f,g,h,i

    I have a few ideas on how I may achieve this but honestly they will be overly complex, and thats assuming they work at all which is not likely.... so I figured why not ask to see if any of you guys had any elegant solution for that, I realize I can use a lot of spreadsheets for each step but Id rather take a minimalist view when filling the actual cells with data as in Id love to only have to fill the cells with the end results.


    Thanks Again!

  4. #4
    Valued Forum Contributor kasan's Avatar
    Join Date
    07-22-2009
    Location
    Riga, Latvia
    MS-Off Ver
    Excel 2010
    Posts
    680

    Re: getrows trouble

    After you run Query1 - just keep result of it in some variable/array and then take A - run query and print out the result a,b,c. Then take B, run query and print out the result under already extracted,to get a,b,c,d,e,f. and so on.
    You could write a function with parameter to get query resutls and then just pass those A, B, C as parameters.

  5. #5
    Registered User
    Join Date
    08-21-2012
    Location
    Iowa, USA
    MS-Off Ver
    Excel 2013
    Posts
    75

    Re: getrows trouble

    Ok I ran into 1 problem... Some of the Variables I run through my getrows function have multiple columns in the original table so if I query to select multiple things only 1 column returns...

    So I did this:

    Please Login or Register  to view this content.

    Which I found all over google as a way to fix that problem... Only I get a Run-Time Error '-2147217884 ( 80040e24 ) Rowset does not support fetching backward

    So why am I getting this error when according to a lot of the internet, that is what I need to do to be sure I get all of my records into my array?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Trailing Characters/Space when querying via ADODB.recordset getrows
    By Jay-T in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-27-2016, 08:53 AM
  2. Trouble with VBA and If-then-else
    By lostwithVBA in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-09-2015, 12:03 PM
  3. In a Serious Trouble. Help me.
    By Jabes in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-16-2012, 02:20 PM
  4. IF trouble
    By craighaylett in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-13-2009, 06:49 AM
  5. GetRows()
    By jmicdk in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-07-2009, 10:23 AM
  6. Trouble with an If
    By Zyphlin in forum Excel General
    Replies: 1
    Last Post: 11-16-2007, 03:00 PM
  7. copyFromRecordset - vs - getRows
    By Chris Short in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-14-2005, 01:05 PM

Tags for this Thread

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