+ Reply to Thread
Results 1 to 8 of 8

Add one array to another array

  1. #1
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Australia
    MS-Off Ver
    Excel 2007; Excel 2010
    Posts
    178

    Add one array to another array

    Hi,

    I am still just not getting it.
    I have a range on one sheet which I have added to an array and another range on another sheet added to an array
    If value in array matches value in 2nd array I want to add that value to a 3rd array.
    Just getting stumped here.

    This is what I have to date..
    Please Login or Register  to view this content.
    Thanks for your time

    Lionel
    Last edited by Foreverlearning; 05-17-2012 at 02:53 AM.

  2. #2
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: Add one array to another array

    Please Login or Register  to view this content.
    At this point in your code, there is nothing to preserve.
    vaNames is a 2D array, whereas you are only creating a 1D array.
    The size of this 1D array is the size of the first dimension of vaNames plus one extra element.

    Please Login or Register  to view this content.
    Shouldn't this be:

    Please Login or Register  to view this content.
    As for the rest, it is unclear to me what you are trying to accomplish.

  3. #3
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Add one array to another array

    maybe so
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Australia
    MS-Off Ver
    Excel 2007; Excel 2010
    Posts
    178

    Re: Add one array to another array

    What I was trying to do is really learn how to add a range to an array add another range of names to an array and see which of the first array matched the criteria of the second array and add that to a 3rd array and count the number in that 3rd array.

    Thank you nilem.

    You have given me what I wanted and I really have to study these to fully understand otherwise I am just parroting you.

    By the way can you add non contiguous range to the 1st array as in
    Please Login or Register  to view this content.
    I can't seem to get this to work

    Many thanks
    Lionel

  5. #5
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Add one array to another array

    You have small ranges, so you can use Cells:
    Please Login or Register  to view this content.
    If you want to use arrays, it will look something like this (just for testing):
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Australia
    MS-Off Ver
    Excel 2007; Excel 2010
    Posts
    178

    Re: Add one array to another array

    Hi nilem,

    You are marvelous mate...

    Is there any speed advantage over the cells and the array types.

    I can extend the cells version ok, but the array version looks more complicated.
    I have extended the cells version by quite a few not contiguous ranges so the array version is not that simple to extend.

    Your thoughts

    Lionel.

  7. #7
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Add one array to another array

    Arrays are processed faster, but the filling of array from cells on a worksheet (such as For each cel ... arr(i)=cel.Value) is a slow operation. I think the first code of the post #5 would be most suitable for you.

  8. #8
    Forum Contributor
    Join Date
    06-16-2010
    Location
    Australia
    MS-Off Ver
    Excel 2007; Excel 2010
    Posts
    178

    Re: Add one array to another array

    Thank you mate so are so very helpful.

+ 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