+ Reply to Thread
Results 1 to 10 of 10

Macro to find and print gaps in a number sequence

  1. #1
    Registered User
    Join Date
    03-01-2015
    Location
    Gothenburg
    MS-Off Ver
    13
    Posts
    35

    Macro to find and print gaps in a number sequence

    Hello!

    I m looking for a macro that could loop through a number sequence (starting at any given number, so cant use the Rows function otherwise a formula would work).
    and then if the sequence is broken i would like it to print the missing number(s) in a column.
    See file attached.

    Thankful for any help.

    Best
    Attached Files Attached Files
    Last edited by jheidens; 01-17-2018 at 03:08 PM. Reason: Better sample data

  2. #2
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Macro to find and print gaps in a number sequence

    Try this.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  3. #3
    Registered User
    Join Date
    03-01-2015
    Location
    Gothenburg
    MS-Off Ver
    13
    Posts
    35

    Re: Macro to find and print gaps in a number sequence

    Quote Originally Posted by skywriter View Post
    Try this.
    Please Login or Register  to view this content.


    Amazing, impressed!
    Thank you Skywriter!

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

    Re: Macro to find and print gaps in a number sequence

    Try
    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    03-01-2015
    Location
    Gothenburg
    MS-Off Ver
    13
    Posts
    35

    Re: Macro to find and print gaps in a number sequence

    Quote Originally Posted by jindon View Post
    Try
    Please Login or Register  to view this content.
    You guys are just amazing!
    Thanks alot Jindon it works perfect also with the column containing letters and numerical combined.

  6. #6
    Registered User
    Join Date
    03-01-2015
    Location
    Gothenburg
    MS-Off Ver
    13
    Posts
    35

    Re: Macro to find and print gaps in a number sequence

    Jindon - i have tried to apply your script on another file with the same data but difference is that its a lot more data.
    I have some files i need to apply it on with 350 000 records. It worked great on the file you uploaded. Unfortunately this is too high level VBA for me to adjust i'm more on a beginners level.

    What happens is that i do get an error.
    I will upload data and file which this occured on and would be very thankful if you could have a look at it?
    Last edited by jheidens; 01-18-2018 at 08:32 AM.

  7. #7
    Registered User
    Join Date
    03-01-2015
    Location
    Gothenburg
    MS-Off Ver
    13
    Posts
    35

    Re: Macro to find and print gaps in a number sequence

    Skywriter i have also tried your script on the last previously uploaded file and it tells me "subscript out of range" error.
    Although it worked great on the file you uploaded!
    Last edited by jheidens; 01-18-2018 at 08:31 AM.

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

    Re: Macro to find and print gaps in a number sequence

    Because your missing numbers exceeds the row limit i.e. 1048576.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    03-01-2015
    Location
    Gothenburg
    MS-Off Ver
    13
    Posts
    35

    Re: Macro to find and print gaps in a number sequence

    Amazing thank you!
    Works like a charm now!

    Edited
    Last edited by jheidens; 01-18-2018 at 09:32 AM.

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

    Re: Macro to find and print gaps in a number sequence

    1)
    Don't quote whole posts -- it's just clutter. If you are responding to a post out of sequence, limit quoted content to a few relevant lines that makes clear to whom and what you are responding

    For normal conversational replies, try using the QUICK REPLY box below.


    2)
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

+ 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: 7
    Last Post: 06-08-2015, 08:39 AM
  2. [SOLVED] Macro to Find the next number in sequence from a table.
    By brent_milne in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-12-2015, 10:40 AM
  3. Reconstruct sequence and fill gaps with zeroes
    By rover233 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-01-2013, 01:46 PM
  4. Excel 2007 : print number sequence on 2 part ncr paper
    By quinterod in forum Excel General
    Replies: 1
    Last Post: 03-31-2011, 10:35 AM
  5. Find Next Number in Sequence
    By additude in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-14-2008, 01:30 PM
  6. [SOLVED] How do I find the next higher number in a sequence?
    By CasaJay in forum Excel General
    Replies: 4
    Last Post: 06-23-2006, 05:45 PM
  7. How do I find a missing number in a sequence of numbers?
    By Nash in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 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