+ Reply to Thread
Results 1 to 4 of 4

Function to replace sequential numbers

  1. #1
    Registered User
    Join Date
    07-12-2014
    Location
    Chicago
    MS-Off Ver
    2013
    Posts
    67

    Function to replace sequential numbers

    Hello Excel Geniuses, I'm looking for a UDF that can allow me to select a range of cells that have sequential values, and replace the all but the top and bottom values with a dash. If there is a blank cell somewhere, the space between would be replaced by a comma. Here's an example of what I'm looking for:

    I have tables that look like this. The numbers will always be in order, but won't always be in every cell.

    A B C D E F G
    1 2 5 6 7
    5 6 7 8
    3 14




    So, let's say I've put the UDF in the last cell in every row. for example, the first one would look like this:

    Please Login or Register  to view this content.
    I'd want to be able to select the cells in each row and it would look something like this:

    A B C D E F G
    1 2 5 6 7 2,5-7
    5 6 7 8 10 5,6-8,10
    3 14 3,14
    Last edited by SoothSailor; 08-26-2014 at 12:44 PM.

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

    Re: Function to replace sequential numbers

    I don't have a UDF that does what you want for on a range of values, but it will work with sequential/non-sequential values separated by a comma in a single cell.

    Using your example above, if cell G1 had the value 1,2,5,6,7 you would use the formula
    Please Login or Register  to view this content.
    to get 1-2,5-7.

    UDF is as follows:

    Please Login or Register  to view this content.
    There are other macros out there that will concatenate your values into one cell separated by a comma.
    Last edited by Brawnystaff; 08-26-2014 at 12:40 PM.

  3. #3
    Registered User
    Join Date
    07-12-2014
    Location
    Chicago
    MS-Off Ver
    2013
    Posts
    67

    Re: Function to replace sequential numbers

    I have another UDF that does exactly that! I'll try it.

  4. #4
    Registered User
    Join Date
    07-12-2014
    Location
    Chicago
    MS-Off Ver
    2013
    Posts
    67

    Re: Function to replace sequential numbers

    Solved! Thank you so much!

+ 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. Using If to Sum() non-sequential numbers
    By robert_shindorf in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 01-23-2009, 08:20 PM
  2. Using sequential numbers
    By Rhonda F in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-22-2007, 03:34 AM
  3. sequential numbers
    By phildaug in forum Excel General
    Replies: 8
    Last Post: 05-10-2007, 01:18 PM
  4. Sequential Numbers - HELP!
    By dave7822 in forum Excel General
    Replies: 2
    Last Post: 09-05-2005, 01:05 PM
  5. Non-sequential VLOOKUP function -OR- sequential sort of web query
    By Eric S in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-28-2005, 04: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