Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 12th, 2007, 02:55 AM
Authorized User
 
Join Date: Apr 2007
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default To find the missing numbers in a list of cells

In an excel sheet i have numbers in A column. Suppose, in column A the numbers are as follows:
1
2
3
7
8
11
12
13

I need a formula in excel to find out only those numbers which are missing in the list. For example, in the above list, 4,5,6,9,10 numbers are missing.


Yogesh
__________________
Yogesh
 
Old December 12th, 2007, 06:55 PM
Friend of Wrox
 
Join Date: Feb 2007
Posts: 163
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Are the numbers always going to be in sequential order?

Assuming they will, this should work:

--------------------------------------------------------------
'Checks column A for missing numbers, putting them in cell B1 separated by columns.
  Dim iRowOn As Long, iNumber As Long, sMissing As String
  iRowOn = 1 'Or first cell with number. Will think it's done at first blank line
  iNumber = 1
  Do While Cells(iRowOn, 1).Value <> ""
    If iNumber < Cells(iRowOn, 1).Value Then
      Do While iNumber < Cells(iRowOn, 1).Value
        sMissing = sMissing & ", " & iNumber
        iNumber = iNumber + 1
      Loop
    End If
    iRowOn = iRowOn + 1
  Loop
  Cells(1, 2).Value = Right(sMissing, Len(SMissing) - 2)
--------------------------------------------------------------

This is rough but should do what you want given that the numbers are sorted with no blank rows between numbers.

Hope this helped point you in the right direction.

 
Old December 13th, 2007, 02:02 AM
Authorized User
 
Join Date: Apr 2007
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, I will try in vba, but i just want a excel formula for that.

Yogesh





Similar Threads
Thread Thread Starter Forum Replies Last Post
Compare two table - Find missing record lawsoncobol Access VBA 5 August 4th, 2006 01:18 AM
find and replace numbers in a string -- wildcards cs8271506 Beginning VB 6 3 March 1st, 2006 07:41 AM
Anybody find the missing code in ch6? nickolas BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 January 29th, 2006 10:38 AM
How do I quickly find version numbers for A-M-P? ababb BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 2 January 11th, 2005 02:26 PM
Find out missing record hari-kumar-vadakkeveedu SQL Server 2000 3 October 15th, 2004 01:09 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.