+ Reply to Thread
Results 1 to 4 of 4

Looking for consectuive numbers bewteen hypen

  1. #1
    Forum Contributor
    Join Date
    09-04-2013
    Location
    USA
    MS-Off Ver
    Excel 365
    Posts
    263

    Looking for consectuive numbers bewteen hypen

    I am looking to get all number combinations for numbers stored in a column as text, with some of the number separated by a hypen to abbreviate a number range (e.g. 1-3 would be 1,2,3), and some just singles numbers (e.g. 6).

    Attached is a sample workbook, with data I am starting with in Sheet "Before" and the results in sheet "After". Any ideas on how to do it? Thanks.
    Attached Files Attached Files

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

    Re: Looking for consectuive numbers bewteen hypen

    Hi Brawnystaff,
    try this
    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Looking for consectuive numbers bewteen hypen

    Please Login or Register  to view this content.
    If solved remember to mark Thread as solved

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

    Re: Looking for consectuive numbers bewteen hypen

    Horribly inefficient as it is compared to the two VBA offerings, if you're after a formula-based solution then first go to Name Manager and define a new name, Arry1, as:

    =MMULT(0+(ROW($A$1:$A$3)>=TRANSPOSE(ROW($A$1:$A$3))),1+MMULT(IFERROR(0+TRIM(MID(SUBSTITUTE($A$1:$A$3,"-",REPT(" ",33)),33*{0,1}+1,33)),0+$A$1:$A$3),{-1;1}))

    (Amend the range ($A$1:$A$3) as required, though make sure it is an absolute reference (the "dollar signs"), as here.)

    The array formula** is then:

    =IFERROR(SMALL(ROW(INDIRECT(SUBSTITUTE(INDEX("A"&SUBSTITUTE($A$1:$A$3,"-","-A"),MATCH(TRUE,Arry1>=ROWS($1:1),0)),"-",":"))),IFERROR(1+ROWS($1:1)-LOOKUP(ROWS($1:1),1+Arry1),ROWS($1:1))),"")

    Copy down until you start to get blanks for the results.

    Regards


    **Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
    Last edited by XOR LX; 06-18-2014 at 12:55 PM.
    Click * below if this answer helped

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

+ 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. how to add hypen between 2 numbers in cell
    By JKONT in forum Excel General
    Replies: 2
    Last Post: 12-23-2012, 10:57 AM
  2. Replies: 0
    Last Post: 06-28-2012, 08:02 AM
  3. Stopping Excel from interpreting hypen
    By Bob Summers in forum Excel General
    Replies: 2
    Last Post: 12-26-2009, 07:43 AM
  4. [SOLVED] HOW TO i HAVE OTHER CELLS GENERATE CONSECTUIVE MONTHS
    By Cathy in Florida in forum Excel General
    Replies: 1
    Last Post: 07-15-2006, 10:17 AM
  5. Ignoring everthing after a hypen
    By Steve in forum Excel General
    Replies: 5
    Last Post: 09-09-2005, 04:05 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