Find Missing Sequence

FlashNZ

New Member
Joined
Mar 3, 2021
Messages
29
Office Version
  1. 365
Platform
  1. Windows
Hi,

I want to identify missing numbers in a sequence of numbers but with conditions. I can't figure out to write a IF statement to do this (or maybe it needs a Macro).

I have highlighted the sequence I am trying to identify in the image in the column FY. But I only want it to identify this break in the sequence if the ItemID is the same and if the MSQ is greater than 0. So I guess I want:- IF MSQ > 0 AND ItemID = the ItemID above it then evaluate the sequence and report "Missing" in a new column E, otherwise leave it blank.

Hope this makes sense.

Gordon
 

Attachments

  • Capture.JPG
    Capture.JPG
    85.4 KB · Views: 16

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
For next time this might be useful so helpers do have to manually type sample data. It will usually get you faster & more accurate answers. :)

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.

Would something like this help?

21 10 21.xlsm
ABCD
1
2a20201 
3a20201 
4a20201 
5a20201 
6a20221x
7a20221 
8a20221 
9a20221 
10b20200 
11b20200 
12b20220 
13b20220 
14b20220 
Seq Break
Cell Formulas
RangeFormula
D2:D14D2=IF(AND(A2=A1,C2>0,B2<>B1),"x","")
 
Upvote 0
HI,

Thanks for the quick reply and have now downloaded the add in and posted table below.

I don't think I explained myself properly at the start, yes your formula identifies the highlighted break in the sequence for NUT-FENOIL but the gap I want to identify is that 2021 is missing (goes from 2020 to 2022). Your formula also identifies the change for NUT-FENUGR from 2015 to 2016. I only want it identified if there is a gap so if NUT-FENGUR went from 2015 to 2017 I would want it identified. Changing from 2015 to 2016 is ok.

Does that explain it?

Book1.xlsx
ABCDE
1Item NumberFYPeriod No:MSQMissing Sequnce
2NUT-FENOIL20208390 
3NUT-FENOIL20209390 
4NUT-FENOIL202010390 
5NUT-FENOIL202011390 
6NUT-FENOIL202012390 
7NUT-FENOIL20221390x
8NUT-FENOIL20222390 
9NUT-FENOIL20223390 
10NUT-FENOIL20224390 
11NUT-FENOIL20225380 
12NUT-FENOIL20226380 
13NUT-FENOIL20227380 
14NUT-FENOIL20228380 
15NUT-FENOIL20229380 
16NUT-FENOIL202210380 
17NUT-FENOIL202211380 
18NUT-FENOIL202212380 
19NUT-FENUGR201510 
20NUT-FENUGR201520 
21NUT-FENUGR201530 
22NUT-FENUGR201540 
23NUT-FENUGR201550 
24NUT-FENUGR201560 
25NUT-FENUGR201570 
26NUT-FENUGR201580 
27NUT-FENUGR201590 
28NUT-FENUGR2015100 
29NUT-FENUGR2015110 
30NUT-FENUGR2015120 
31NUT-FENUGR201610x
32NUT-FENUGR201620 
33NUT-FENUGR201630 
34NUT-FENUGR201640 
35NUT-FENUGR201650 
Sheet1
Cell Formulas
RangeFormula
E2:E35E2=IF(AND(A2=A1,C2>0,B2<>B1),"x","")
 
Upvote 0
OK, try adding one extra condition. Does this do it?

Excel Formula:
=IF(AND(A2=A1,C2>0,B2<>B1,B2<>N(B1)+1),"x","")
 
Upvote 0
Hi,

I figured it out: =IF(AND(A2=A1,D2>0,(B2-B1)>1),"x","")

Thanks for your help.

Gordon
 
Upvote 0

Forum statistics

Threads
1,215,028
Messages
6,122,753
Members
449,094
Latest member
dsharae57

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top