+ Reply to Thread
Results 1 to 13 of 13

CombineTwoArrays Function

  1. #1
    Forum Expert
    Join Date
    12-24-2004
    Location
    Sweden
    Posts
    1,256

    CombineTwoArrays Function

    I have tried to find a Function that can combine two Arrays into one.

    Something like =CombineTwoArrays(Array1,Array2)
    Array1 is a 1:n, Array2 is also 1:n
    CombineTwoArrays is 2:n

    Is there a simple way to do this?

  2. #2
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: CombineTwoArrays Function

    Hi olasa,

    By combining two arrays, what do you actually wanted to achieve, please share more. Thanks.

    Regards,
    DILIPandey

    <click on below 'star' if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), dilipandey@gmail.com

  3. #3
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,309

    Re: CombineTwoArrays Function

    Take a look at http://www.cpearson.com/Excel/VBAArrays.htm

  4. #4
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474

    Re: CombineTwoArrays Function

    Is this what you mean?

    Please Login or Register  to view this content.

  5. #5
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: CombineTwoArrays Function

    to add the values in 2 arrays (ranges) D1:G3 and D7:G9
    Please Login or Register  to view this content.
    you can use this UDF

    Please Login or Register  to view this content.
    You will have to enter this UDF as an arrayformula: ctrl-shift-enter

    {=snb7(D1:G3,D7:G9)}
    and autofill the adjacent cells correponding to the range's size
    Last edited by snb; 02-05-2012 at 11:37 AM.



  6. #6
    Forum Expert
    Join Date
    12-24-2004
    Location
    Sweden
    Posts
    1,256

    Re: CombineTwoArrays Function

    Hello everyone,

    I appreciate all the replies but no success (see attached).
    It looks like you have already given me a solution and - I am sure it's something simple - but I just can't get it to work.
    Any Aha suggestions?

    //Ola


    ---
    I have this formula =ScatterChart(G34:H38;;;;;;;;;;;;;;;1841892) in another (big file)*.
    Here I would like to replace G34:H38 with the new Function.
    My x-y values comes from various rows in a large spreadsheet, but 'Sparklines for Excel' want (unfortunatelly) a continous region.

    I have also tried
    http://www.cpearson.com/excel/VBAArrays.htm (could not get it to work)
    http://www.dailydoseofexcel.com/arch...bining-arrays/ (not working)
    Attached Files Attached Files

  7. #7
    Valued Forum Contributor
    Join Date
    07-29-2009
    Location
    Belgium
    MS-Off Ver
    Excel 2003/Excel 2010
    Posts
    534

    Re: CombineTwoArrays Function

    Maybe too simplistic, but couldn't you use the index-function?
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    12-24-2004
    Location
    Sweden
    Posts
    1,256

    Re: CombineTwoArrays Function

    Yes it's too simple for a matrix of ScatterCharts (see encl. picture).

    The idea was to use a Function =CombineTwoArrays(Product1, Product2) that draws the data directly from the DataTable (row19).
    To avoid to go via a ChartData table (row30) - where the number of combinations grows exponetially (messy).
    'Sparklines for Excel' want a continous area (see function Fx row)... otherwise it would have been (too) easy.

    //Ola
    Attached Files Attached Files

  9. #9
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: CombineTwoArrays Function

    @wher

    I think you are right:
    PHP Code: 
    =INDEX($D$5:$G$7;2*(ROW(1:3)-1)+1;) 
    see the attachment.
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    12-24-2004
    Location
    Sweden
    Posts
    1,256

    Re: CombineTwoArrays Function

    snb & wher, sorry but your suggestions are roughly what I already have (see the Book1.xlsm attachement).

    The 'Sparkline for Excel' function =scatterchart(xyarea,,,) function want one continous area.
    I need a single cell formula that can pass the whole xyarea (array) as one continouse area in one single cell. i.e. join row C20:G20 & C23:G23
    I think I can only be done by a UDF, but do surprice me.
    //Ola

  11. #11
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: CombineTwoArrays Function

    you can union 2 ranges and make it a named range and use that in your formula.

    Please Login or Register  to view this content.
    PHP Code: 
    function =scatterchart(snb2,,,) 
    Last edited by snb; 02-06-2012 at 10:08 AM.

  12. #12
    Forum Expert
    Join Date
    12-24-2004
    Location
    Sweden
    Posts
    1,256

    Re: CombineTwoArrays Function

    snb, sorry but I just can't get anything to work.
    I've tried all suggestions and I the closest I got was =0 otherwise i just get =#REF! or =#VALUE!

  13. #13
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: CombineTwoArrays Function

    You can use either:
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    you can use the named range snb_qq in your formula. ( the only thing to prevent is using a 'reseved name', that's why snb2, snb7 doesn't work in E2007/E2010 because that is being reserved for a column).

+ 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