+ Reply to Thread
Results 1 to 7 of 7

Identify and display the first and last cell of numeric ranges from one column in another

  1. #1
    Registered User
    Join Date
    07-26-2013
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2013
    Posts
    2

    Identify and display the first and last cell of numeric ranges from one column in another

    Identify the first cell (starting cell) and the last cell End Cell) in multiple numeric ranges from one column and display the results in a separate column.

    Figure-5.png

    I have several spreadsheets containing tens of thousands of rows of sequential numeric postal codes that span a few columns. I have been trying to simplify how this data is processed so that I can greatly reduce the amount of keystrokes I have to enter through out the project.

    Column A contains a complete list of sequential numeric postal codes.

    Column B contains unique codes that can be found in Column A. I have already figured out how to arrange each unique value so that they line up with the identical value in column A. The result is a series of ranges (Point #6)

    Column C is where I am stumped and require assistance.

    For simplicity I have included a screen shot which has been edited to point to certain requirements (Please excuse the fact that it starts with Point #6, I have been able to solve the first 5 points already.)

    For each numeric range created in column B, I need to identify the first and last cell and display the results in the same row but in Column C. (Red Boxes in Column C) I must also follow these following guidelines.

    Point #7 - The cells between each numeric range must remain blank.
    Point #8 - Ranges that have only one cell only require one cell to function as both the START and
    STOP cells for that particular range.
    Point #9 - Ranges that have two cells require only the display of the START and STOP cells in Column
    C.
    Point #10 - If the ranges contain 3 or more cells then the cells between the START and STOP cells in
    Column C must remain blank.

    I need to write a formula that I can copy/paste down the length of Column C that will accomplish this task and save me from time consuming manual entry of the data.

    I need to have these particular START and STOP cells identified because my next task is to turn each range into Regular Expressions (RegEx) displayed in Column D in the row containing the STOP cell. (Any help on accomplishing that would be greatly appreciated as well)

    Thank you in advance

  2. #2
    Valued Forum Contributor
    Join Date
    05-20-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2013
    Posts
    941

    Re: Identify and display the first and last cell of numeric ranges from one column in anot

    See if this works for you...

    =IF(OR(B3="",AND(ISNUMBER(B2),ISNUMBER(B4))),"",B3)

  3. #3
    Valued Forum Contributor
    Join Date
    05-20-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2013
    Posts
    941

    Re: Identify and display the first and last cell of numeric ranges from one column in anot

    Quote Originally Posted by Kicks1981 View Post
    ...

    I need to have these particular START and STOP cells identified because my next task is to turn each range into Regular Expressions (RegEx) displayed in Column D in the row containing the STOP cell. (Any help on accomplishing that would be greatly appreciated as well)

    Thank you in advance
    Please demonstrate what you want in column D.

  4. #4
    Registered User
    Join Date
    07-26-2013
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2013
    Posts
    2

    Re: Identify and display the first and last cell of numeric ranges from one column in anot

    Thank you so much jhren, you have literally just saved me hours of work!

    Fig-1.jpgFig-2.jpg

    I have attached two screen shots from the file I am currently working on the created the START and STOP cells using your formula above. (Fig-1.0).

    What I now need to do is take each of those individual sets of START STOP cells and create a RegEx and place the " | " symbol at the end of each RegEx (Fig-2.0). As you can see the ranges can go from anywhere between 1 cell in length to thousands later on. I need something that will identify the different ranges accurately.

    Up until now have been utilizing an online RegEx generator, but upon looking at what was involved in its creation, I think that it may be something that can be applied to this problem in the form of a macro? VBA? (Not sure which is the proper terminology) you can locate the utility here

    http://utilitymill.com/edit/Regex_For_Range (I have had a few slight issues with this utility as sometimes it neglects to place " - " when its required.

    If you could help that would be the most amazing thing to happen to me all weekend, hell I might actually get to enjoy the few remaining hours of this weekend!

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Identify and display the first and last cell of numeric ranges from one column in anot

    Please do not upload a picture of your file...rather, upload a sample of your workbook, showing what data you are working with, a few samples of your expected outcome is (manually entered is ok) and how you arrived at that. (exclude sensitive info). Pictures are pretty much impossible to edit, and no-one wants to re-type your data for you

    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  6. #6
    Valued Forum Contributor
    Join Date
    05-20-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2013
    Posts
    941

    Re: Identify and display the first and last cell of numeric ranges from one column in anot

    Will there ever be a range than spans into three decades, e.g. 20729-20741, where 20729 is in the 20720-2029 decade and 20741 is in the 20740-20749 decade and the 20730-20739 decade is in between...

    ...and would the example be coded 207(29|3[0-9]|40)| or something else?

    Also, will there ever be a range that spans into two or more centuries, e.g. 20798-20802 or 20799-20902, and how would they be coded?

  7. #7
    Valued Forum Contributor
    Join Date
    05-20-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2013
    Posts
    941

    Re: Identify and display the first and last cell of numeric ranges from one column in anot

    In cell D3, and copy down...
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Caveat: Only works for ranges having same first 3 digits and spanning not more than two [absolute] decades.

    To do better, I suggest going with VBA code (aka macro), but someone else will have to write it.

+ 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. Replies: 1
    Last Post: 04-23-2013, 12:46 AM
  2. [SOLVED] Identify the previous row is numeric
    By sambuka in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-06-2012, 12:07 AM
  3. Identify numeric in column then....
    By sambuka in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-28-2012, 11:53 AM
  4. Display Numeric Result in Cell
    By davehunter in forum Excel General
    Replies: 4
    Last Post: 07-27-2007, 07:11 AM
  5. VBA - Identify Begin/End of Cell Ranges
    By ajocius in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-26-2005, 11: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