Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
CM
 
Posts: n/a
Default A list of Consecutive Integers, can I search for missing integers

If I have a column of sorted consecutive Integers, can I search that column
and find cells that might be missing a consecutive Integer? We have a list
of customer numbers and if we don't have a number in the sorted sequential
order we want to be able to know that. Any help?
  #2   Report Post  
Harlan Grove
 
Posts: n/a
Default

CM wrote...
If I have a column of sorted consecutive Integers, can I search that column
and find cells that might be missing a consecutive Integer? We have a list
of customer numbers and if we don't have a number in the sorted sequential
order we want to be able to know that. Any help?


If you have a column of sorted integers in a range named LST in which
all the integers should be consecutive, your first test should be
whether there are any duplicates. That can be done using

=SUMPRODUCT((LST<"")/(COUNTIF(LST,LST)+(LST="")))=COUNT(LST)

If this returns TRUE, then all numbers in the list are distinct.

Next, check that they're all integers.

=SUMPRODUCT(--(MOD(LST,1)=0))=COUNT(LST)

Once these two tests have been passed, it's simple to check if they're
consecutive.

=MAX(LST)-MIN(LST)=COUNT(LST)-1

If they're not, then the index within LST of the k_th nonconsecutive
integer is given by the array formula

=SMALL(IF(OFFSET(LST,0,0,COUNT(LST)-1,1)<OFFSET(LST,1,0,COUNT(LST)-1,1)-1,
ROW(INDIRECT("2:"&ROWS(LST)))),k)

  #3   Report Post  
Barb Reinhardt
 
Posts: n/a
Default

Why not insert a helper column and calculate the difference between the two
values.

"CM" wrote:

If I have a column of sorted consecutive Integers, can I search that column
and find cells that might be missing a consecutive Integer? We have a list
of customer numbers and if we don't have a number in the sorted sequential
order we want to be able to know that. Any help?

  #4   Report Post  
Duke Carey
 
Posts: n/a
Default

This works with a starting value of 1000 in cell A2, so that the integer
MINUS 998 = the Row#, and returns the row of the first nonconsecutive integer:

=MAX(--(A2:A28-998=ROW(A2:A28))*ROW(A2:A28))

"CM" wrote:

If I have a column of sorted consecutive Integers, can I search that column
and find cells that might be missing a consecutive Integer? We have a list
of customer numbers and if we don't have a number in the sorted sequential
order we want to be able to know that. Any help?

  #5   Report Post  
Duke Carey
 
Posts: n/a
Default

And it needs to be entered as an array formula with

Ctrl-Shift-Enter


"Duke Carey" wrote:

This works with a starting value of 1000 in cell A2, so that the integer
MINUS 998 = the Row#, and returns the row of the first nonconsecutive integer:

=MAX(--(A2:A28-998=ROW(A2:A28))*ROW(A2:A28))

"CM" wrote:

If I have a column of sorted consecutive Integers, can I search that column
and find cells that might be missing a consecutive Integer? We have a list
of customer numbers and if we don't have a number in the sorted sequential
order we want to be able to know that. Any help?



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ooh .. Linking a list to a list to an output cell StrawDog Excel Discussion (Misc queries) 4 August 22nd 05 09:51 PM
Update master list with other lists Chab Excel Worksheet Functions 0 August 4th 05 03:46 PM
Search for most recent date from list of dates Wendell Excel Discussion (Misc queries) 1 June 23rd 05 12:04 AM
Drop down List problems LHearn Excel Discussion (Misc queries) 2 June 20th 05 10:37 PM
Using advanced filter to search for criteria in a list Potatosalad2 Excel Discussion (Misc queries) 1 June 8th 05 03:08 AM


All times are GMT +1. The time now is 05:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"