+ Reply to Thread
Results 1 to 3 of 3

how to write a code to combine the number in an array

  1. #1
    Registered User
    Join Date
    12-29-2011
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2003
    Posts
    2

    how to write a code to combine the number in an array

    Hi I would like to write a function to return a string as follows. Can someone help me? Thank you.

    1
    2
    3
    4
    5
    9
    10

    1-5, 9-10 <== all in one cell

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: how to write a code to combine the number in an array

    Sorry, but we might need a bit more information:

    1. Is this function going to be code in VBA, or does it have to be a formula?
    2. Is there an upper limit to the number of elements you'll want to combine in one cell?
    3. Will the data always be in ascending order?
    4. Are the maximum and minimum values for the numbers in the array (e.g. will they always be in the range 1-10?)
    5. Will there be duplicate values in the data?
    6. Will the data always be integer values?

    To pre-empt the answer to the first question, this is almost certainly a nightmare to do as a formula, so you're probably looking at some VBA code.

  3. #3
    Registered User
    Join Date
    12-29-2011
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2003
    Posts
    2

    Red face Re: how to write a code to combine the number in an array

    Thank you for replying my questions. and Sorry for not being specific. Here is my thoughts

    1. Is this function going to be code in VBA, or does it have to be a formula?
    Yes, it is going to be code in VBA as a function to deal with this kind of array with a column of numbers.

    2. Is there an upper limit to the number of elements you'll want to combine in one cell?
    No. all numbers are located in one column and the upper limit is like over 1000. If there is a limit for a string in a cell, the upper limit should be defined. I would like to build a function that has array range as input like A2:A200. The number might not be the sequence of numbers but they are in order like 1, 2, 4, 5, 6, 13, 14, 15, 25, 27, 30.....

    3. Will the data always be in ascending order?
    Yes, it will.
    4. Are the maximum and minimum values for the numbers in the array (e.g. will they always be in the range 1-10?)
    Maximum is something like 7000. Minimum varies and it depends on the first number in the array.

    5. Will there be duplicate values in the data?
    No, there is no duplicate values.

    6. Will the data always be integer values?
    Yes, only integer values.

    If you have any other concerns, please feel free to ask. It would be appreciated.

    Gary

+ 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