+ Reply to Thread
Results 1 to 9 of 9

Ways of referring to entire Array row or column

  1. #1
    Forum Contributor
    Join Date
    10-30-2014
    Location
    England
    MS-Off Ver
    2007 / 365
    Posts
    281

    Ways of referring to entire Array row or column

    Is there any way to refer to an entire row (or column for that matter) of a 2D Array, or must any reference only be to a single item/position i.e. array(1,1) etc ?

    For example, I if I have a 10 row x 10 column array and I want to join all of the values in each row, can I refer in some way to each array row to do that, or must I loop through each item to join them up?
    Last edited by 6StringJazzer; 09-17-2022 at 03:34 PM. Reason: clarified title

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,991

    Re: Ways of referring to entire Array row or column

    What you want to do is called slicing an array and VBA doesn't support it. Someone may have a clever way to do this but it's not built into the language as a straightforward feature.

    I updated your title to say what you are actually asking.
    Last edited by 6StringJazzer; 09-18-2022 at 12:07 PM. Reason: fixed typo
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor
    Join Date
    10-30-2014
    Location
    England
    MS-Off Ver
    2007 / 365
    Posts
    281

    Re: Ways of referring to entire Array row or column

    Thought as much. Thanks for confirming.

  4. #4
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Ways of referring to entire Array row or column

    Hello. 6StringJazzer says it right:

    Quote Originally Posted by 6StringJazzer View Post
    What you want to do it called slicing an array and VBA doesn't support it.
    _________________________

    However, Excel can do it efficiently as follows:

    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: Ways of referring to entire Array row or column

    Perhaps in this second version everything will be clearer:
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,697

    Re: Ways of referring to entire Array row or column

    Don't know if I understood things right but if your intent is to output just a single Row only or a single Column only from a multidimensional array, this does that.
    Change references as required.
    Please Login or Register  to view this content.
    Or do you have something like this in mind?
    Please Login or Register  to view this content.
    Last edited by jolivanes; 09-18-2022 at 01:04 AM.
    The inherent weakness of the liberal society: a too rosy view of humanity.

  7. #7
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,697

    Re: Ways of referring to entire Array row or column

    The thread is marked as solved but no indication which suggestion was the right one.

  8. #8
    Forum Contributor
    Join Date
    10-30-2014
    Location
    England
    MS-Off Ver
    2007 / 365
    Posts
    281

    Re: Ways of referring to entire Array row or column

    Apologies, I marked as Solved after the initial answer from 6StringJazzer. But thanks to all. These solutions work very well and I can adapt to my needs.

  9. #9
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,697

    Re: Ways of referring to entire Array row or column

    Thanks for letting us know that you can live with the solutions.
    Good luck. It'll be busy tomorrow.

+ 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. [SOLVED] 2 ways array with multiple returns
    By Vibov in forum Excel General
    Replies: 1
    Last Post: 11-24-2020, 09:34 AM
  2. Replies: 7
    Last Post: 03-12-2017, 03:20 PM
  3. [NEED HELP]Array Formula by Referring to Few Criteria in Different Table
    By ulala2 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-27-2016, 08:52 AM
  4. [SOLVED] Referring at an Array in different worksheet
    By Holbeck_Ghyll in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-05-2014, 10:42 AM
  5. Typing an array into a formula rather than referring to an array of cells
    By Cookstein2 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-03-2013, 12:59 PM
  6. Referring to an array column or row of LinEst function
    By HammerTime in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-14-2010, 01:11 AM
  7. Referring to multiple elements of an array (VB)
    By Phil in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-18-2005, 12:50 AM

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