+ Reply to Thread
Results 1 to 5 of 5

Ideas for pulling and storing multiple values from data source

Hybrid View

Lewis2010 Ideas for pulling and storing... 07-13-2011, 02:33 PM
davegugg Re: Ideas for pulling and... 07-13-2011, 02:39 PM
Lewis2010 Re: Ideas for pulling and... 07-13-2011, 02:50 PM
davegugg Re: Ideas for pulling and... 07-13-2011, 03:02 PM
Lewis2010 Re: Ideas for pulling and... 07-13-2011, 03:05 PM
  1. #1
    Registered User
    Join Date
    12-20-2010
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    21

    Ideas for pulling and storing multiple values from data source

    Hey, I havent quite hammered out the code Im going to use yet but just wanted to see if anyone had any ideas. Im looking for a way to store values that meet a certain criteria in order to use them later as a variable in another part of my macro. The data is being pulled from a SQL server in the first part of the macro.

    Sample Data:
    Source Number
    JE 1234
    AR 5236
    AR 5236
    AR 5478

    I would be looking to store the numbers 5236 and 5478 based on the criteria Source= "AR". As shown in the sample data there will be duplicate numbers and I only want to store one instance of it. Later in the macro I will be using each number as a condition for calculation/lookup.

    Im not looking for exact code, instead maybe any ideas people want to contribute. Thanks in advance!

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Ideas for pulling and storing multiple values from data source

    Can you change the SQL to only pull distinct numbers?
    Other than that, you can used the advanced filter to only give you unique entries.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Registered User
    Join Date
    12-20-2010
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Ideas for pulling and storing multiple values from data source

    Yea Im going to try both of those. The thing I really wasnt sure about was in there a way to store the values in an array and later reference that array as a single variable and loop through it performing and operation for each value.

  4. #4
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Ideas for pulling and storing multiple values from data source

    If you are running sql, you probably have a reference to ADO or DAO. If that is true, you should be able to use a recordset. You can load a recordset using SQL and loop through each element using recordset functions.

  5. #5
    Registered User
    Join Date
    12-20-2010
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Ideas for pulling and storing multiple values from data source

    I'll have to check that out thanks Dave! I'm new to VBA and SQL Im a finance and accounting guy who has been teaching myself when I have time so I appreciate all the input.

+ 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