+ Reply to Thread
Results 1 to 12 of 12

Help on a UDF, Find consecutives numbers In single Cell, with "-"

  1. #1
    Forum Contributor
    Join Date
    10-21-2012
    Location
    miami, florida usa
    MS-Off Ver
    Excel 2007
    Posts
    260

    Help on a UDF, Find consecutives numbers In single Cell, with "-"

    Hi all,

    I know is boring what i'm going to ask you...
    (Before this post, on this forum i search 1906 post about consecutive, and none of those match my need.. )
    So
    I need find consecutive Numbers in a singles Cell but each numbers have a leading zero and "-"
    (Dash)

    My problem is that the UDF that i found on this forum, is for numbers with out leading zero with coma ",",
    so even if change the "," by "-", still getting a error Because the Code is designed to Read numbers Formats different than mine..

    My Numbers are located in Cell G12 (down), and the message that i need to show
    in the cell result is :

    If Found :
    0 Consecutives --> 0
    2 Consecutives --> 2
    3 consecutives --> 3
    4 consecutives --> 4
    5 consecutives --> 5
    2 Set of consecutives --> 2S

    Example of 0 consecutives --> 01-04-07-12-25-30
    Example of 2 consecutives --> 01-02-07-12-25-30
    Example of 3 consecutives --> 01-02-03-12-25-30
    Example of 4 consecutives --> 01-02-03-04-25-30
    Example of 5 consecutives --> 01-02-03-04-05-30
    Example of 2 sets of consecutive s --> 01-02-07-12-25-26

    BTW my numbers start on Cell G12 down..
    ______G12_______
    01-02-03-20-21-25


    This is the Module that i'm getting hard time... Please any help??


    Please Login or Register  to view this content.


    Thank you so much




    Best regards

    David
    Last edited by david gonzalez; 03-14-2014 at 11:30 PM. Reason: bad spelling

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Help on a UDF, Find consecutives numbers In single Cell, with "-"

    Hi david,

    Try this:

    Please Login or Register  to view this content.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Contributor
    Join Date
    10-21-2012
    Location
    miami, florida usa
    MS-Off Ver
    Excel 2007
    Posts
    260

    Re: Help on a UDF, Find consecutives numbers In single Cell, with "-"

    Hi Mr MarvinP,

    It gave me an error 9
    located on :
    Please Login or Register  to view this content.
    David

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Help on a UDF, Find consecutives numbers In single Cell, with "-"

    Hey David,

    You asked for a UDF and the above doesn't really do that. Find attached a much better answer. It will handle longer strings and you can put them anywhere in the sheet. You don't need to put them in Col H.

    I think this is what you are really wanting anyhow.
    Attached Files Attached Files

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Help on a UDF, Find consecutives numbers In single Cell, with "-"

    Most likely you didn't have 5 numbers separated by dashes. The below UDF answer is much better as it uses the number of numbers in the array instead of trusting there will be exactly 5 numbers.

    The UBound(Arrs) tells how many numbers there are. Step through the code in the attached file below and see if you have questions about it... Feel free to ask...

    http://www.excel-easy.com/vba/examples/debugging.html or
    http://www.cpearson.com/Excel/DebuggingVBA.aspx

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Help on a UDF, Find consecutives numbers In single Cell, with "-"

    UDF
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    10-21-2012
    Location
    miami, florida usa
    MS-Off Ver
    Excel 2007
    Posts
    260

    Re: Help on a UDF, Find consecutives numbers In single Cell, with "-"

    Hi Mr MarvinP,

    It work great Mr MarvinP, Thank you so much !!!!!!!!

    I'll search about the difference between UDF and the code you've sent me..
    Sorry, i'm still a lil dumb about excel ..


    Best regards

    David

  8. #8
    Forum Contributor
    Join Date
    10-21-2012
    Location
    miami, florida usa
    MS-Off Ver
    Excel 2007
    Posts
    260

    Re: Help on a UDF, Find consecutives numbers In single Cell, with "-"

    Hi Mr Jindon,

    Thank you so much !!!, i haven't try your code but i will,

    By the way, important code in my sheet came from you !


    Thank you a lot !!

    Best regards

    David
    Last edited by david gonzalez; 03-15-2014 at 12:13 AM. Reason: correcting spelling

  9. #9
    Forum Contributor
    Join Date
    10-21-2012
    Location
    miami, florida usa
    MS-Off Ver
    Excel 2007
    Posts
    260

    Re: Help on a UDF, Find consecutives numbers In single Cell, with "-"

    Hi Mr marvinP,

    I have interest to learn VBA and i know that there are many resources online,
    The problem is that most theses learn resources cover many lil details,
    that at the end the newbee (like me) get more confused..

    Can you recommend me some resource but to cover just the Basic VBA....
    then for later while coding, i go to details and more difficult steps..
    For example, first I would like to learn the first basic 10 steps,
    Can you ??


    Thank you so much !!



    Best regards from Miami..

    David

  10. #10
    Forum Contributor
    Join Date
    10-21-2012
    Location
    miami, florida usa
    MS-Off Ver
    Excel 2007
    Posts
    260

    Re: Help on a UDF, Find consecutives numbers In single Cell, with "-"

    Hi Mr MarvinP,

    Matter of Fact the 2 links from post #5, (excel-easy and cpearson) have a basic learn material
    on "how to" of VBA

    Thank you


    Best regards from miami.

    David

  11. #11
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Help on a UDF, Find consecutives numbers In single Cell, with "-"

    I really like John Walkenback's style. Here is his first basic VBA book.

    http://www.amazon.com/Excel-Programm.../dp/1118490371

  12. #12
    Forum Contributor
    Join Date
    10-21-2012
    Location
    miami, florida usa
    MS-Off Ver
    Excel 2007
    Posts
    260

    Re: Help on a UDF, Find consecutives numbers In single Cell, with "-"

    Hi Mr MarvinP,

    i just have it the VBA for dummy..I'll start now..

    Thank you for your kindness..

    Best regards

    David.

+ 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. [SOLVED] Alter Macro from "Find cell location if blank" T o "Find cell location if "MyWord"
    By capson in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-06-2014, 09:47 AM
  2. [SOLVED] Count "A" and "V" as separate characters in a single cell
    By sportboy712 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-04-2013, 12:26 PM
  3. [SOLVED] "how to search missing numbers in a single cell "from a min/max numbers library.."
    By david gonzalez in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-22-2012, 04:58 PM
  4. How to find the "value/sum" of numbers in a single cell
    By bshelman in forum Excel General
    Replies: 6
    Last Post: 05-05-2008, 10:26 AM
  5. Replies: 4
    Last Post: 01-21-2008, 08:22 AM

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