+ Reply to Thread
Results 1 to 22 of 22

Single Cell Array

  1. #1
    Registered User
    Join Date
    04-25-2017
    Location
    Bulgaria
    MS-Off Ver
    2016
    Posts
    11

    Question Single Cell Array

    When I write {={1;2;3;4;5}} in A1, and then {=SUM(A1)} in B2, B2 displays 1, when it should display 15.
    When I write {=SUM({1;2;3;4;5})} it displays 15.
    So how do I make this work with single cell arrays, without filling my sheet with my arrays' values, and without manually writing my arrays into the functions which use them?

  2. #2
    Valued Forum Contributor loginjmor's Avatar
    Join Date
    01-31-2013
    Location
    Cedar Rapids, Iowa
    MS-Off Ver
    Excel 2013
    Posts
    1,073

    Re: Single Cell Array

    Hi -

    I think you have to have a cell for each element of your array. You can't put them all in one cell. However, you can use the Excel Name Manager, on the Formulas Tab to Define a Name for an array. So you go to Formulas, Define Name, which brings up a window for New Name. Enter any name, for example Array1. Then in the window titled Refers To: enter ={1,2,3,4,5} Then click OK.

    Now you can enter your formula =SUM(Array1) and you will get a result of 15. This doesn't fill you sheet with array values and is pretty easy to insert in formulas since Excel will bring your element Name up as you type. Just pick it from the list.

    Hope this helps.
    ____________________________________________
    If this has solved your problem, please edit the thread title to add the word [SOLVED] at the beginning. You can do this by
    -Go to the top of the first post
    -Select Thread Tools
    -Select Mark thread as Solved

    If I have been particularly helpful, please "bump" my reputation by pressing the small star in the lower left corner of my post.

  3. #3
    Registered User
    Join Date
    04-25-2017
    Location
    Bulgaria
    MS-Off Ver
    2016
    Posts
    11

    Re: Single Cell Array

    Oh, yes! that helped! Thanks

  4. #4
    Valued Forum Contributor loginjmor's Avatar
    Join Date
    01-31-2013
    Location
    Cedar Rapids, Iowa
    MS-Off Ver
    Excel 2013
    Posts
    1,073

    Re: Single Cell Array

    Great! Glad I could help. Thank you for the Rep! If you are satisfied with the answer, please don't forget to mark your thread as SOLVED per the directions at the bottom of this post.

  5. #5
    Registered User
    Join Date
    04-25-2017
    Location
    Bulgaria
    MS-Off Ver
    2016
    Posts
    11

    Re: Single Cell Array

    Yeah, I'll mark it as solved, but I kind a have 1 more question related:
    How do I address a range of elements of this array? If I have {6;2;0;0;3;5;-2;...} how can I use the range of elements - from 2-nd to 6-th (for example)?
    And is there any function like "LENGTH" that will return the amount of elements each array contains?

  6. #6
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Single Cell Array

    Quote Originally Posted by WereElf View Post
    If I have {6;2;0;0;3;5;-2;...} how can I use the range of elements - from 2-nd to 6-th (for example)?
    What precisely do you mean? To return a reduced array containing just the elements between the relative positions you specify? So in your example, for:

    {6;2;0;0;3;5;-2}

    you'd want to return

    {2;0;0;3;5}

    ?

    Quote Originally Posted by WereElf View Post
    And is there any function like "LENGTH" that will return the amount of elements each array contains?
    COUNT if all elements within the array are numeric. COUNTA otherwise, though note that the latter will equally consider null strings ("") for the count.

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  7. #7
    Valued Forum Contributor loginjmor's Avatar
    Join Date
    01-31-2013
    Location
    Cedar Rapids, Iowa
    MS-Off Ver
    Excel 2013
    Posts
    1,073

    Re: Single Cell Array

    Hi -

    You can access individual elements with the INDEX function. So, for example if your array is named Array1, you could use the formula =INDEX(Array1,2) to pull out the second element.

    As for your other question, I agree with XOR LX. It depends on what you're going to do with the data. There are several functions in Excel that work with arrays such as SUM, SUMPRODUCT, INDEX, MATCH and many others as well as turning some of the standard functions that don't normally accept arrays into Array Functions using Ctrl-Shift-Enter such as IF statements.

    Can you give us some examples of what you're going to do with the data?

  8. #8
    Registered User
    Join Date
    04-25-2017
    Location
    Bulgaria
    MS-Off Ver
    2016
    Posts
    11

    Re: Single Cell Array

    Quote Originally Posted by XOR LX View Post
    What precisely do you mean? To return a reduced array containing just the elements between the relative positions you specify? So in your example, for:

    {6;2;0;0;3;5;-2}

    you'd want to return

    {2;0;0;3;5}

    ?
    That's exactly what I want. How do I do that?

    And yeah, count would work for getting the array's length

  9. #9
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Single Cell Array

    Assuming your original array is named Arry1 and that you put your desired start and end indices (e.g. 2 and 6) in A1 and B1 respectively:

    INDEX(Arry1,N(IF(1,A1+ROW(INDEX(A:A,1):INDEX(A:A,1+B1-A1))-1)))

    The above may require committing as an array formula**, depending upon how it is employed within the workbook.

    Regards

  10. #10
    Registered User
    Join Date
    04-25-2017
    Location
    Bulgaria
    MS-Off Ver
    2016
    Posts
    11

    Re: Single Cell Array

    Works like a charm! Thanks

  11. #11
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Single Cell Array

    You're welcome!

    Cheers

  12. #12
    Registered User
    Join Date
    04-25-2017
    Location
    Bulgaria
    MS-Off Ver
    2016
    Posts
    11

    Re: Single Cell Array

    By the way, after analyzing the formula for a bit, I noticed something odd: doesn't IF(1;..) always return true? what's the point of this if?

  13. #13
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Single Cell Array

    Very good question!

    To which the answer is: yes, it does always return TRUE.

    And I'm still not entirely sure why this artificial, self-evident coercion is necessary, I'm afraid.

    Lori makes a decent effort at an explanation here.

    Regards

  14. #14
    Registered User
    Join Date
    04-25-2017
    Location
    Bulgaria
    MS-Off Ver
    2016
    Posts
    11

    Re: Single Cell Array

    Now there is 1 more thing troubling me:
    I want the calculations I make to be private/hidden, and the arrays I use as well.
    When I lock the sheet - I can still view the global arrays. Any way to prevent people from seeing the global arrays I use, after locking the sheet?
    I know that not many people are aware of the existence of the global arrays (at least not the ones who are going to use my product), but don't wanna take any chances.

  15. #15
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Single Cell Array

    You can do this with some VBA:

    Please Login or Register  to view this content.
    Regards

  16. #16
    Registered User
    Join Date
    02-25-2019
    Location
    Tel-Aviv, Israel
    MS-Off Ver
    office 365
    Posts
    4

    Re: Single Cell Array

    XOR LX
    i have tried using your formula (entered as an array formula, pls see the attached PrtSc) but it doesn't seem to work?
    would you know why?
    thx in advance, david

    Attachment1.png

  17. #17
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Single Cell Array

    Hi,

    Can't see any screenshots, though an actual workbook is always more useful, of course.

    Regards

    Edit: Apologies, I see it now. Remove the quotation marks from your definition for Array1.

    Regards
    Last edited by XOR LX; 02-25-2019 at 03:55 PM.

  18. #18
    Registered User
    Join Date
    02-25-2019
    Location
    Tel-Aviv, Israel
    MS-Off Ver
    office 365
    Posts
    4

    Re: Single Cell Array

    Stupid me, many thx, can i push my luck and ask you if its possible to select non consecutive members as well?
    for example if i wanted to select the first, third and fourth?
    rgds, david

  19. #19
    Registered User
    Join Date
    02-25-2019
    Location
    Tel-Aviv, Israel
    MS-Off Ver
    office 365
    Posts
    4

    Re: Single Cell Array

    by the way, i have been looking for this for some weeks now, i knew about the dereferencing technique but it was with the use of constants (e.g.- {1,3} ) and i couldnt find a way to reference it to a cell or a function. many thx for this!

  20. #20
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Single Cell Array

    So do you still need some help with this?

    Regards

  21. #21
    Registered User
    Join Date
    02-25-2019
    Location
    Tel-Aviv, Israel
    MS-Off Ver
    office 365
    Posts
    4

    Re: Single Cell Array

    Sure, i would love to learn how to get this done, rgds, david

  22. #22
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Single Cell Array

    So why can't you use an array constant corresponding to the desired entries, similar to that you indicated in post #19? If you need a dynamic, non-static array, can you clarify what the conditions are for these "non-consecutive members"?

    Regards

+ 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. Array in single cell
    By timsah in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-04-2017, 08:40 AM
  2. Using single cell value in Array Function
    By mcrowley in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-09-2016, 10:28 AM
  3. Single cell array calculation
    By NyoGoat in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-26-2013, 03:53 PM
  4. R2 value in a single cell, not set as an array
    By ReferenceGoblin in forum Excel General
    Replies: 1
    Last Post: 06-13-2011, 09:56 AM
  5. Replies: 2
    Last Post: 12-18-2009, 10:59 AM
  6. [SOLVED] Array input in one single cell
    By Ischias in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-29-2005, 05:50 PM
  7. [SOLVED] Entering array in single cell
    By nospaminlich in forum Excel General
    Replies: 6
    Last Post: 02-11-2005, 01:06 PM

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