Complex autofill formula

%3CLINGO-SUB%20id%3D%22lingo-sub-1404815%22%20slang%3D%22en-US%22%3ERe%3A%20Complex%20autofill%20formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1404815%22%20slang%3D%22en-US%22%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F673704%22%20target%3D%22_blank%22%3E%40jalverson%3C%2FA%3E%26nbsp%3B%3CBR%20%2F%3E%3CBR%20%2F%3EIt's%20a%20bit%20tricky%20to%20read%20your%20formula...%3CBR%20%2F%3E%3CBR%20%2F%3EIf%20you'd%20share%20a%20sample%20file%20-%20it%20would%20be%20easier%20to%20grasp%20and%20provide%20a%20solution.%3CBR%20%2F%3E%3CBR%20%2F%3EMy%20gut%20feel%20is%20use%26nbsp%3Bsumproduct%20%2B%20choose%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20TRICK%20is%20that%20if%20you%20do%20a%20compare%20two%20values%20and%20change%20that%20into%20a%20number%20(proceed%20with%20double%20minus%20%22--%22)%20-%20then%20if%20matches%2C%20that%20yields%20%3D1%20but%20if%20it%20doesn't%20match%2C%20it%20yields%20%3D0%3CBR%20%2F%3E%3CBR%20%2F%3EFor%20instance%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3D--(%22a%22%3D%22a%22)%20%26lt%3B%26lt%3B%20returns%20%3D1%3CBR%20%2F%3E%3CBR%20%2F%3E%3D--(%22a%22%3D%22b%22)%20%26lt%3B%26lt%3B%20returns%20%3D0%3CBR%20%2F%3E%3CBR%20%2F%3ESo%20you%20can%20build%20your%20criteria%20and%20total%20the%20evaluations%20up%20-%20that%20yields%20integer%20that%20you%20can%20feed%20into%20the%20choose%20function.%3CBR%20%2F%3E%3CBR%20%2F%3EBut%20as%20I%20said%20-%20if%20you'd%20upload%20a%20sample%20file%20-%20that%20would%20help%20(and%20potentially%20render%20my%20suggestion%20above%20totally%20useless%20%3A))%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1404717%22%20slang%3D%22en-US%22%3EComplex%20autofill%20formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1404717%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20creating%20a%20column%20of%20cells%20(column%20e)%20on%20a%20data%20sheet%20that%20I%20want%20to%20auto-fill%20with%20the%20contents%20of%20a%20different%20cell%20from%26nbsp%3B%20datasheet%20named%20Blad%201%20(column%20A)%20if%20the%20contents%20in%20column%20F%20fall%20within%20a%20range%20of%20numbers%20within%20the%20%C3%85tg%C3%A4rderskoder%20datasheet's%20column%20B%20and%20return%20nothing%20if%20it%20does%20not%20match%20that%20criteria.%26nbsp%3B%20I%20have%20completed%20the%20initial%20cell%20formula%20which%20seems%20to%20work%20and%20returned%20the%20result%20I%20expected%2C%20but%20when%20I%20drag%20down%20to%20auto%20format%2C%20the%20autofill%20places%20a%20combination%20of%20different%20results%20(several%20cells%20from%20the%20Blad%201%20datasheet%20into%20the%20same%20cell).%26nbsp%3B%20For%20example%3A%20(is%20in%20Swedish%20(om%3Dif%2C%20och%3Dand%2C%20eller%3Dor%2C%20%3B%3D%2C)%20I%20apologize%20for%20the%20Swedish%20formula%2C%20but%20I%20do%20not%20write%20swedish%20well%20and%20needed%20help%20on%20an%20english%20forum.)....%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DOM(ELLER(F2%26gt%3B%3D%C3%85tg%C3%A4rdskoder!%24B%244%3BF2%26lt%3B%3D%C3%85tg%C3%A4rdskoder!%24B%2425%3BF2%26gt%3B%3D%C3%85tg%C3%A4rdskoder!%24B%2430%3BF2%26lt%3B%3D%C3%85tg%C3%A4rdskoder!%24B%2446)%3BBlad1!%24A%243%3B%22%22)%26amp%3BOM(OCH(F2%26gt%3B%3D%C3%85tg%C3%A4rdskoder!%24B%2426%3BF2%26lt%3B%3D%C3%85tg%C3%A4rdskoder!%24B%2429)%3BBlad1!%24A%244%3B%22%22)%26amp%3BOM(OCH(F2%26gt%3B%3D%C3%85tg%C3%A4rdskoder!%24C%2447%3BF2%26lt%3B%3D%C3%85tg%C3%A4rdskoder!%24B%24216)%3BBlad1!%24A%247%3B%22%22)%26amp%3BOM(OCH(F2%26gt%3B%3D%C3%85tg%C3%A4rdskoder!%24B%24217%3BF2%26lt%3B%3D%C3%85tg%C3%A4rdskoder!%24B%24255)%3BBlad1!%24A%248%3B%22%22)%26amp%3BOM(OCH(Plan!F2%26gt%3B%3D%C3%85tg%C3%A4rdskoder!%24B%24256%3BPlan!F2%26lt%3B%3D%C3%85tg%C3%A4rdskoder!%24B%24277)%3BBlad1!%24A%248%3B%22%22)%26amp%3BOM(OCH(F2%26gt%3B%3D%C3%85tg%C3%A4rdskoder!%24B%24278%3BF2%26lt%3B%3D%C3%85tg%C3%A4rdskoder!%24B%24332)%3BBlad1!%24A%246%3B%22%22)%26amp%3BOM(OCH(F2%26gt%3B%3D%C3%85tg%C3%A4rdskoder!%24B%24333%3BF2%26lt%3B%3D%C3%85tg%C3%A4rdskoder!%24B%24337)%3BBlad1!%24A%2415%3B%22%22)%26amp%3BOM(OCH(F2%3D%C3%85tg%C3%A4rdskoder!%24B%24338)%3BBlad1!%24A%249%3B%22%22)%26amp%3BOM(OCH(F2%26gt%3B%3D%C3%85tg%C3%A4rdskoder!%24B%24339%3BF2%26lt%3B%3D%C3%85tg%C3%A4rdskoder!%24B%24350)%3BBlad1!%24A%2411%3B%22%22)%26amp%3BOM(OCH(F2%26gt%3B%3D%C3%85tg%C3%A4rdskoder!%24B%24351%3BF2%26lt%3B%3D%C3%85tg%C3%A4rdskoder!%24B%24355)%3BBlad1!%24A%2413%3B%22%22)%26amp%3BOM(OCH(F2%26gt%3B%3D%C3%85tg%C3%A4rdskoder!%24B%24356%3BF2%26lt%3B%3D%C3%85tg%C3%A4rdskoder!%24B%24378)%3BBlad1!%24A%2410%3B%22%22)%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EResult%20returns%20as%20Code%202%20(which%20is%20what%20I%20expected)%3C%2FP%3E%3CP%3EHowever%2C%20when%20I%20drag%20down%20to%20autoformat%20the%20formula%2C%20the%20result%20vary%20and%20will%20return%20Code%202%20and%20code%207%20or%20some%20other%20number%20that%20it%20matches.%26nbsp%3B%20How%20do%20I%20rectify%20this%20or%20is%20there%20a%20better%20formula%20to%20utilize%20multiple%20contingencies%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20help%20would%20be%20appreciated%20if%20it%20is%20possible.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20loaded%20a%20copy%20of%20the%20workbook%20and%20the%20sheet%20I%20am%20configuring%20is%20the%20one%20named%20Plan.%26nbsp%3B%20I%20have%20set%20notes%20in%20the%20cells%20in%20Column%20E%20so%20you%20understand%20better%20what%20is%20resulting.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1404717%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1404855%22%20slang%3D%22en-US%22%3ERe%3A%20Complex%20autofill%20formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1404855%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F53759%22%20target%3D%22_blank%22%3E%40Austris%20Bahanovskis%3C%2FA%3E%26nbsp%3BThanks%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20uploaded%20a%20copy%20of%20the%20Workbook%20that%20is%20in%20question.%26nbsp%3B%20Again%2C%20in%20swedish%2C%20so%20I%20am%20not%20sure%20if%20you%20can%20read%20or%20open%20it.%26nbsp%3B%20However%2C%20I%20have%20placed%20notes%20with%20Yellow%20highlighting%20on%20the%20column%20in%20question.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1406901%22%20slang%3D%22en-US%22%3ERe%3A%20Complex%20autofill%20formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1406901%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F673704%22%20target%3D%22_blank%22%3E%40jalverson%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHey!%3C%2FP%3E%3CP%3ESorry%2C%20got%20tied%20up%20all%20day...%3C%2FP%3E%3CP%3EBTW%3A%20if%20I%20open%20office%20file%20in%20my%20local%20MsOffice%20-%20the%20formulas%20get%20translated%20into%20my%20locale.%20So%2C%20I%20don't%20need%20to%20know%20Swedish%20%3CLI-EMOJI%20id%3D%22lia_winking-face%22%20title%3D%22%3Awinking_face%3A%22%3E%3C%2FLI-EMOJI%3E%20(I%20wouldn't%20mind%2C%20though!)%3C%2FP%3E%3CP%3EAnyways%2C%20it's%20not%20that%20I've%20got%20a%20ready%20solution%20for%20you%20but%20this%20might%20help%20you%20(as%20I%20don't%20know%20if%20I'll%20have%20enough%20time%20to%20solve%20it%20entirely%20for%20you)%20-%20have%20a%20look%20at%20the%201st%20IF%20of%20your%20formula%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Annotation%202020-05-20%20222510.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F193408i148F2B16BEEC633C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22Annotation%202020-05-20%20222510.jpg%22%20alt%3D%22Annotation%202020-05-20%20222510.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3Ethis%20bit%3A%3C%2FP%3E%3CP%3EF2%26gt%3B%3D%C3%85tg%C3%A4rdskoder!%24B%244%3C%2FP%3E%3CP%3Ewith%20your%20data%20will%20ALWAYS%20return%20TRUE%20because%20the%20MIN(F)%20%3D11121%2C%20i.e.%2C%20the%20smallest%20number%20in%20column%20%5B%C3%85tg%C3%A4rds-kod%5D%20is%20%3D11121.%20Then%20in%20tab%20%5B%C3%85tg%C3%A4rdskoder%5D%20column%20B%20also%20the%20smallest%20number%20is%2011121%2C%20hence%20this%20comparison%26nbsp%3BF2%26gt%3B%3D%C3%85tg%C3%A4rdskoder!%24B%244%20(for%20the%20entire%20column%20F)%20will%20always%20return%20TRUE%20because%20any%20number%20in%20column%20F%20is%20greater%20than%20or%20equal%20to%20the%20%C3%85tg%C3%A4rdskoder!%24B%244.%3C%2FP%3E%3CP%3ENow%2C%20since%20your%20first%20IF%20checks%20for%20OR%2C%20that%20makes%20it%20ALWAYS%20return%20TRUE%20which%20in%20turn%20ALWAYS%20makes%20the%20IF%20to%20return%20value%20%222%22%20from%26nbsp%3BBlad1!%24A%243.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESure%2C%20there%20are%20various%20ways%20how%20to%20write%20this%20formula%20in%20a%20more%20elegant%20way%20but%20if%20the%20above%20solves%20your%20issue%20-%20maybe%20that's%20enough%20%3CLI-EMOJI%20id%3D%22lia_slightly-smiling-face%22%20title%3D%22%3Aslightly_smiling_face%3A%22%3E%3C%2FLI-EMOJI%3E%3C%2FP%3E%3CP%3EPost%20back%20if%20this%20doesn't%20resolve%20your%20issue%20%26lt%3B%20I'll%20try%20to%20check%20in%20again%20(cannot%20promise%20though...)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1408003%22%20slang%3D%22en-US%22%3ERe%3A%20Complex%20autofill%20formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1408003%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F673704%22%20target%3D%22_blank%22%3E%40jalverson%3C%2FA%3E%26nbsp%3BCan't%20help%20thinking%20that%20you%20are%20choosing%20a%20complicated%20manner%20to%20achieve%20something%20that's%20fairly%20easy%20if%20you%20create%20an%20intermediate%20table%20where%20you%20link%20%22%C3%85tg%C3%A4rdskoder%22%20with%20%22Komponentkoder%22.%20The%20key%20seems%20to%20lie%20in%20the%20first%20two%20digits%20of%20the%20%C3%85tg%C3%A4rdskod.%20I%20created%20such%20a%20table%20in%20%22Blad%201%22%20and%20referred%20to%20it%20in%20column%20E%20(Plan)%20with%20a%20simple%20VLOOKUP.%20You%20need%20to%20check%20if%20I%20mapped%20the%20correct%20Komponent%20to%20the%20correct%20%C3%85tg%C3%A4rd%20groups.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20have%20a%20look%20at%20the%20attached%20file.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETrevlig%20helg!!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1408073%22%20slang%3D%22en-US%22%3ERe%3A%20Complex%20autofill%20formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1408073%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F403176%22%20target%3D%22_blank%22%3E%40Riny_van_Eekelen%3C%2FA%3E%26nbsp%3BThis%20worked%20great.%26nbsp%3B%20It%20is%20exactly%20what%20I%20was%20trying%20to%20achieve%20in%20a%20complex%20manner.%26nbsp%3B%20I%20haven't%20used%20VLOOKUP%20in%20about%2015%20years%20and%20forgot%20about%20it.%26nbsp%3B%20Thanks%20for%20the%20help!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1408099%22%20slang%3D%22en-US%22%3ERe%3A%20Complex%20autofill%20formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1408099%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F53759%22%20target%3D%22_blank%22%3E%40Austris%20Bahanovskis%3C%2FA%3E%26nbsp%3BThanks%20for%20the%20answer.%26nbsp%3B%20I%20wasn't%20considering%20the%20if(or(%26gt%3B%3D%20would%20always%20return%20the%20the%20cell%20I%20was%20referring%20to%20in%20every%20cell.%26nbsp%3B%20It%20makes%20sense%20now.%26nbsp%3B%20Appreciate%20the%20input.%26nbsp%3B%20Thanks!%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

I am creating a column of cells (column e) on a data sheet that I want to auto-fill with the contents of a different cell from  datasheet named Blad 1 (column A) if the contents in column F fall within a range of numbers within the Åtgärderskoder datasheet's column B and return nothing if it does not match that criteria.  I have completed the initial cell formula which seems to work and returned the result I expected, but when I drag down to auto format, the autofill places a combination of different results (several cells from the Blad 1 datasheet into the same cell).  For example: (is in Swedish (om=if, och=and, eller=or, ;=,) I apologize for the Swedish formula, but I do not write swedish well and needed help on an english forum.)....

 

=OM(ELLER(F2>=Åtgärdskoder!$B$4;F2<=Åtgärdskoder!$B$25;F2>=Åtgärdskoder!$B$30;F2<=Åtgärdskoder!$B$46);Blad1!$A$3;"")&OM(OCH(F2>=Åtgärdskoder!$B$26;F2<=Åtgärdskoder!$B$29);Blad1!$A$4;"")&OM(OCH(F2>=Åtgärdskoder!$C$47;F2<=Åtgärdskoder!$B$216);Blad1!$A$7;"")&OM(OCH(F2>=Åtgärdskoder!$B$217;F2<=Åtgärdskoder!$B$255);Blad1!$A$8;"")&OM(OCH(Plan!F2>=Åtgärdskoder!$B$256;Plan!F2<=Åtgärdskoder!$B$277);Blad1!$A$8;"")&OM(OCH(F2>=Åtgärdskoder!$B$278;F2<=Åtgärdskoder!$B$332);Blad1!$A$6;"")&OM(OCH(F2>=Åtgärdskoder!$B$333;F2<=Åtgärdskoder!$B$337);Blad1!$A$15;"")&OM(OCH(F2=Åtgärdskoder!$B$338);Blad1!$A$9;"")&OM(OCH(F2>=Åtgärdskoder!$B$339;F2<=Åtgärdskoder!$B$350);Blad1!$A$11;"")&OM(OCH(F2>=Åtgärdskoder!$B$351;F2<=Åtgärdskoder!$B$355);Blad1!$A$13;"")&OM(OCH(F2>=Åtgärdskoder!$B$356;F2<=Åtgärdskoder!$B$378);Blad1!$A$10;"")  

 

Result returns as Code 2 (which is what I expected)

However, when I drag down to autoformat the formula, the result vary and will return Code 2 and code 7 or some other number that it matches.  How do I rectify this or is there a better formula to utilize multiple contingencies?

 

Any help would be appreciated if it is possible.

 

Thanks!

 

I have loaded a copy of the workbook and the sheet I am configuring is the one named Plan.  I have set notes in the cells in Column E so you understand better what is resulting.

 

 

6 Replies
@jalverson 

It's a bit tricky to read your formula...

If you'd share a sample file - it would be easier to grasp and provide a solution.

My gut feel is use sumproduct + choose

The TRICK is that if you do a compare two values and change that into a number (proceed with double minus "--") - then if matches, that yields =1 but if it doesn't match, it yields =0

For instance:

=--("a"="a") << returns =1

=--("a"="b") << returns =0

So you can build your criteria and total the evaluations up - that yields integer that you can feed into the choose function.

But as I said - if you'd upload a sample file - that would help (and potentially render my suggestion above totally useless :))

@Austris Bahanovskis Thanks,

 

I have uploaded a copy of the Workbook that is in question.  Again, in swedish, so I am not sure if you can read or open it.  However, I have placed notes with Yellow highlighting on the column in question.

@jalverson 

Hey!

Sorry, got tied up all day...

BTW: if I open office file in my local MsOffice - the formulas get translated into my locale. So, I don't need to know Swedish (I wouldn't mind, though!)

Anyways, it's not that I've got a ready solution for you but this might help you (as I don't know if I'll have enough time to solve it entirely for you) - have a look at the 1st IF of your formula:

Annotation 2020-05-20 222510.jpg

this bit:

F2>=Åtgärdskoder!$B$4

with your data will ALWAYS return TRUE because the MIN(F) =11121, i.e., the smallest number in column [Åtgärds-kod] is =11121. Then in tab [Åtgärdskoder] column B also the smallest number is 11121, hence this comparison F2>=Åtgärdskoder!$B$4 (for the entire column F) will always return TRUE because any number in column F is greater than or equal to the Åtgärdskoder!$B$4.

Now, since your first IF checks for OR, that makes it ALWAYS return TRUE which in turn ALWAYS makes the IF to return value "2" from Blad1!$A$3.

 

Sure, there are various ways how to write this formula in a more elegant way but if the above solves your issue - maybe that's enough

Post back if this doesn't resolve your issue < I'll try to check in again (cannot promise though...)

@jalverson Can't help thinking that you are choosing a complicated manner to achieve something that's fairly easy if you create an intermediate table where you link "Åtgärdskoder" with "Komponentkoder". The key seems to lie in the first two digits of the Åtgärdskod. I created such a table in "Blad 1" and referred to it in column E (Plan) with a simple VLOOKUP. You need to check if I mapped the correct Komponent to the correct Åtgärd groups.

 

Please have a look at the attached file.

 

Trevlig helg!!

@Riny_van_Eekelen This worked great.  It is exactly what I was trying to achieve in a complex manner.  I haven't used VLOOKUP in about 15 years and forgot about it.  Thanks for the help!

@Austris Bahanovskis Thanks for the answer.  I wasn't considering the if(or(>= would always return the the cell I was referring to in every cell.  It makes sense now.  Appreciate the input.  Thanks!