+ Reply to Thread
Results 1 to 5 of 5

Convert list of alpha numeric into ranges

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

    Convert list of alpha numeric into ranges

    HI- I have a list of alpha numeric strings where some follow contiguous ranges and then at times they don't. I'm looking to take this list and convert it to ranges instead of the list I have. for example, the list starts at ABC000000001 and is contiguous until it gets to ABC000048185 (Cell B2819). So the first range would be ABC000000001- ABC000048185. The next range would be ABC000057279-ABC000057305 and then ABC000060977-ABC000061022 and then ABC000096509-ABC000096541 and then ABC000096542-ABC000112813. I want to eliminate all of the contiguous strings and just list the ranges. Every time there is a gap, that is a new range. By gap I mean the difference between the value in the B column and the value in the cell below in the A column is greater than 1. The 2,821 rows where ABC000000001 goes to ABC000048185 would be converted to one row ABC000000001- ABC000048185. I am able to get the ending strings for all of the ranges with a formula but getting the corresponding beginning strings is giving me a problem. I attached the spreadsheet. Thanks!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,082

    Re: Convert list of alpha numeric into ranges

    Ok try this.

    in C1
    =IFERROR(IF(RIGHT(B1,9)+1=RIGHT(A2,9)+0,1,0),0)
    and copy this down the column
    (This helper column is an indicator of whether the next row is contiguous or not).


    in D1
    =A1

    in D2
    =IF(C1=1,D1,A2)
    and copy this down the column
    (This helper column is either the start of a range copied down or the start of a new range)

    in E1
    =IF(C1=1,"",B1)
    and copy this down the column
    (This helper column is either a blank if contiguous or the end of a contiguous range)

    Now place an Autofilter on columns D and E
    Select column E filter and UNTICK Blanks so Blanks aren't listed.

    This now gives a list of rows where only column D and E are filled.

    Column D is either the start of a new range or the start of a contiguous range that began above that row.
    Column E is blank if the row is contiguous otherwise it is the end value of a range.
    But since you've eliminated the blanks using the filter

    the result is a list (which can be copied elsewhere) of non-contiguous ranges of column A and B
    Last edited by Special-K; 01-10-2018 at 12:32 PM.
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

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

    Re: Convert list of alpha numeric into ranges

    Thank you very much, That is what I needed!
    Question- I understand the first formula is to derive if the range is contiguous or not and mark it yes (1) or No (0)
    Can you explain the last part of the formula as to why you use "+0" and what does the ",0)" at the end do? Thanks again!
    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,082

    Re: Convert list of alpha numeric into ranges

    ABC000000001 is a string but so is the 000000001 part of it.
    The +0 turns 000000001 into 1 so it is regarded as a number so we can compare it with the next row down in column A to see if the next row is contiguous or not.

    The ,0) is the end of the IFERROR() formula.
    The last row of the data was generating a #VALUE error when evaluating IF(RIGHT(B6652,9)+1=RIGHT(A6653,9)+0,1,0)
    So I just put the whole formula in an IFERROR() and returned 0 if the error occurs as the next row is not continguous as it's the end of the data.

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

    Re: Convert list of alpha numeric into ranges

    Thank you for the explanation.

+ 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. Convert Alpha characters back to numeric
    By CNE5x in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-13-2013, 11:46 PM
  2. [SOLVED] Convert alpha to numeric & then create formula - Thanks for reading
    By NylaTai in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 07-18-2013, 02:23 PM
  3. VBA Excel 2007 - Convert column alpha to numeric value
    By bmack in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-06-2013, 12:05 AM
  4. Convert alpha-numeric code to date
    By Buchu in forum Excel General
    Replies: 13
    Last Post: 06-04-2012, 12:51 PM
  5. Convert alpha-numeric to numeric
    By michael mac in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-12-2008, 04:13 PM
  6. Replies: 1
    Last Post: 11-28-2006, 02:42 AM
  7. [SOLVED] Convert Alpha to Numeric
    By Vicki in forum Excel General
    Replies: 2
    Last Post: 03-21-2005, 08:06 AM
  8. convert cells containing alpha to numeric
    By ezu in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 01-09-2005, 06:06 PM

Tags for this Thread

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