Auto increment the Invoice number

%3CLINGO-SUB%20id%3D%22lingo-sub-1560954%22%20slang%3D%22en-US%22%3EAuto%20increment%20the%20Invoice%20number%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1560954%22%20slang%3D%22en-US%22%3E%3CP%3EGood%20day%2C%3C%2FP%3E%3CP%3EPlease%20assist%20me%20with%20a%20formulae%20to%20auto%20increment%20the%20Invoice%20number%20after%20looking%20up%20the%20previous%20value%20for%20the%20specific%20client.%3C%2FP%3E%3CP%3ESee%20attached%20file.%3C%2FP%3E%3CP%3EThanks.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1560954%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1560963%22%20slang%3D%22en-US%22%3ERe%3A%20Auto%20increment%20the%20Invoice%20number%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1560963%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F481153%22%20target%3D%22_blank%22%3E%40AK_ABDI%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHow%20about%20this%3F%3C%2FP%3E%3CP%3EIn%20B25%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%3DIF(AND(ISNUMBER(B24)%2CD25%3DD24)%2CB24%2CINDEX(%24B%243%3A%24B%2420%2CMATCH(D25%2C%24D%243%3A%24D%2420%2C0))%2B1)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3Eand%20copy%20it%20down.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1561004%22%20slang%3D%22en-US%22%3ERe%3A%20Auto%20increment%20the%20Invoice%20number%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1561004%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F481153%22%20target%3D%22_blank%22%3E%40AK_ABDI%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOr%20simply%20this...%3C%2FP%3E%3CP%3EIn%20B25%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%3DIF(D25%3DD24%2CB24%2CINDEX(%24B%243%3A%24B%2420%2CMATCH(D25%2C%24D%243%3A%24D%2420%2C0))%2B1)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1561016%22%20slang%3D%22en-US%22%3ERe%3A%20Auto%20increment%20the%20Invoice%20number%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1561016%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20Subodh.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHowever%2C%20I%20expected%20the%20Invoice%20nr.%20to%20auto-increment%20by%201%20as%20long%20it%20is%20a%20new%20shipment%20to%20a%20specific%20customer.%20May%20be%20I%20did%20not%20explain%20myself%20properly%2C%20but%20the%20next%20shipment%20for%20let's%20say%20Al%20Hilal%2C%20should%20have%20Invoice%20nr.%2033%2C%20then%2034%2C%20then%2035.%20The%20Delivery%20note%20number%20also%20increments%20per%20delivery%20and%20is%20not%20bound%20to%20a%20customer.%20Same%20with%20the%20other%20customers.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1561065%22%20slang%3D%22en-US%22%3ERe%3A%20Auto%20increment%20the%20Invoice%20number%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1561065%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F481153%22%20target%3D%22_blank%22%3E%40AK_ABDI%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOkay%20try%20this%20and%20see%20if%20it%20returns%20the%20desired%20output.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20B25%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%3DIF(AND(C25%3DC24%2CD25%3DD24)%2CB24%2CIF(ISNUMBER(MATCH(D25%2CINDEX(D%2424%3AD24%2C)%2C0))%2CMAX(IFERROR(INDEX((D%2424%3AD24%3DD25)*(B%2424%3AB24)%2C)%2C0))%2B1%2CINDEX(%24B%243%3A%24B%2420%2CMATCH(D25%2C%24D%243%3A%24D%2420%2C0))%2B1))%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3Eand%20copy%20it%20down.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1561087%22%20slang%3D%22en-US%22%3ERe%3A%20Auto%20increment%20the%20Invoice%20number%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1561087%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F481153%22%20target%3D%22_blank%22%3E%40AK_ABDI%3C%2FA%3E%26nbsp%3B%2C%20as%20a%20variation%20to%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F394231%22%20target%3D%22_blank%22%3E%40Subodh_Tiwari_sktneer%3C%2FA%3E%26nbsp%3B's%20solution%20(if%20you%20have%20the%20latest%20Dynamic%20Array%20version%20of%20Excel)%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DMAX(FILTER(%24B%243%3A%24B24%2C(%24D%243%3A%24D24%3DD25)*(%24C%243%3A%24C24%3CC25%3E%3C%2FC25%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

Good day,

Please assist me with a formulae to auto increment the Invoice number after looking up the previous value for the specific client.

See attached file.

Thanks.

5 Replies

@A_SIRAT 

How about this?

In B25

=IF(AND(ISNUMBER(B24),D25=D24),B24,INDEX($B$3:$B$20,MATCH(D25,$D$3:$D$20,0))+1)

and copy it down.

@A_SIRAT 

Or simply this...

In B25

=IF(D25=D24,B24,INDEX($B$3:$B$20,MATCH(D25,$D$3:$D$20,0))+1)

 

Thank you Subodh.

 

However, I expected the Invoice nr. to auto-increment by 1 as long it is a new shipment to a specific customer. May be I did not explain myself properly, but the next shipment for let's say Al Hilal, should have Invoice nr. 33, then 34, then 35. The Delivery note number also increments per delivery and is not bound to a customer. Same with the other customers.

@A_SIRAT 

Okay try this and see if it returns the desired output.

 

In B25

=IF(AND(C25=C24,D25=D24),B24,IF(ISNUMBER(MATCH(D25,INDEX(D$24:D24,),0)),MAX(IFERROR(INDEX((D$24:D24=D25)*(B$24:B24),),0))+1,INDEX($B$3:$B$20,MATCH(D25,$D$3:$D$20,0))+1))

and copy it down.

@A_SIRAT , as a variation to @Subodh_Tiwari_sktneer 's solution (if you have the latest Dynamic Array version of Excel):

 

=MAX(FILTER($B$3:$B24,($D$3:$D24=D25)*($C$3:$C24<C25))) + 1