Complex IF formula

%3CLINGO-SUB%20id%3D%22lingo-sub-133233%22%20slang%3D%22en-US%22%3EComplex%20IF%20formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-133233%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20using%20Excel%202013%20and%20trying%20to%20create%20an%20IF%20forumula%3A%3C%2FP%3E%0A%3CP%3EI%20have%20a%20drop%20down%20list%20of%2032%20items%20in%20Cell%20F9.%26nbsp%3B%20If%20they%20selection%20one%20of%20the%20first%2016%20I%20want%20to%20multiply%20Cell%20M9%20by%201.%26nbsp%3B%20If%20they%20select%20one%20of%20the%20second%2016%20I%20want%20to%20multiply%20cell%20L9%20by%20Cell%20M9.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20tried%20nesting%20them%3A%3C%2FP%3E%0A%3CP%3E%3DIF(F9%3D%22Pre-Treat%20Asphalt%22%2C1*M9%2CIF(F9%3D%22Post-Treat%20Asphalt%22%2C1*M9%2CL9*M9)))%3C%2FP%3E%0A%3CP%3EI%20also%20tried%3A%3C%2FP%3E%0A%3CP%3E%3DIF(OR(F9%3D%22Pre-Treat%20Asphalt%22%2C%22Post-Treat%20Asphalt)%2C%221*M9%22%2C%22L9*M9%22)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI'm%20not%20sure%20what%20I'm%20doing%20wrong.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-133233%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20%26amp%3B%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ENeed%20Help%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-133508%22%20slang%3D%22en-US%22%3ERe%3A%20Complex%20IF%20formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-133508%22%20slang%3D%22en-US%22%3E%3CP%3EGiven%20that%20your%20drop-down%20list%20source%20is%20in%20O9%3AO41%20(which%20is%2033%20cells%20not%2032)%2C%20then%20you%20can%20use%20the%20MATCH%20function%20to%20return%20the%20position%20of%20your%20F9%20selection%20within%20the%20source%20list.%26nbsp%3B%20If%20the%20position%20ios%20less%20than%2017%2C%20then%20return%20whatever%20is%20in%20M9%2C%20otherwise%20return%20M9*L9.%3C%2FP%3E%0A%3CPRE%3E%3DIF(MATCH(F9%2C%24O%249%3A%24O%2441%2C0)%26lt%3B17%2CM9%2CM9*L9)%3C%2FPRE%3E%0A%3CP%3EThe%200%20in%20the%20third%20argument%20of%20the%20MATCH%20function%20specifies%20an%20%22exact%20match%22%20which%20is%20OK%20because%20F9%20must%20be%20selected%20from%20the%20list%20in%20%24O%249%3A%24O%2441.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-133323%22%20slang%3D%22en-US%22%3ERe%3A%20Complex%20IF%20formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-133323%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3E%3CSPAN%20class%3D%22short_text%22%3E%3CSPAN%20class%3D%22%22%3EWhat%20happened%20is%3A%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22short_text%22%3EYou%20forget%20to%20enter%20the%20formula%20by%20using%20the%20special%20keystroke%20shortcut%3A%20%3CSTRONG%3ECtrl%2BShift%2BEnter.%3C%2FSTRONG%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22short_text%22%3ESelect%20cell%20N9%2C%20press%20F2%20to%20activate%20the%20edit%20mode%2C%20then%20don't%20hit%20Enter%2C%20but%20press%20%3CSTRONG%3ECtrl%2BShift%2BEnter%3C%2FSTRONG%3E%20simultaneously%2C%20and%20do%20this%20every%20time%20you%20activate%20the%20edit%20mode.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22short_text%22%3EIt's%20an%20%3CA%20href%3D%22https%3A%2F%2Fsupport.office.com%2Fen-us%2Farticle%2FCreate-an-array-formula-e43e12e0-afc6-4a12-bc7f-48361075954d%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Earray%20formula%3C%2FA%3E%2C%20you%20have%20to%20do%20this%20to%20force%20it%20to%20return%20the%20right%20result.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22short_text%22%3E%20After%20that%2C%20drag%20the%20formula%20down%2C%20but%20before%20you%20drag%20it%2C%20you%20have%20to%20make%20the%20range%20absolute%20to%20prevent%20it%20from%20changing%20during%20the%20drag%2C%20so%20just%20replace%20this%3A%26nbsp%3BO9%3AO24%20with%20this%3A%20%24O%249%3A%24O%2424.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22short_text%22%3EGood%20luck%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-133298%22%20slang%3D%22en-US%22%3ERe%3A%20Complex%20IF%20formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-133298%22%20slang%3D%22en-US%22%3E%3CP%3EOkay%20-%20it's%20not%20working%20completely.%26nbsp%3B%20Please%20see%20my%20attachment.%26nbsp%3B%20If%20the%20%22Service%20Item%22%20selected%20is%20O9%3AO24%2C%20then%26nbsp%3B%20%22Subtotal%22%20should%20equal%20the%20%22Rate%22.%26nbsp%3B%20If%20the%20%22Service%20Item%22%20selected%20is%20O25%3AO41%2C%20then%20%22Subtotal%22%20should%20equal%20%22Total%20Hours%22%20times%20%22Rate%22.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWith%20this%20formula%2C%20Subtotal%20will%20equal%20Rate%20only%20if%20O9%20is%20selected%20from%20the%20drop%20down%20menu%20for%20%22Service%20Item%22.%26nbsp%3B%20All%20other%20%22Service%20Item%22%20selections%20(O10%3AO41)%20give%20a%20Subtotal%20of%20%22Total%20Hours%22%20times%20%22Rate%22.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-133278%22%20slang%3D%22en-US%22%3ERe%3A%20Complex%20IF%20formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-133278%22%20slang%3D%22en-US%22%3E%3CP%3EYou%20are%20so%20Awesome!!!%26nbsp%3B%20Thank%20you%20so%20much!!!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-133245%22%20slang%3D%22en-US%22%3ERe%3A%20Complex%20IF%20formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-133245%22%20slang%3D%22en-US%22%3E%3CP%3EI%20advise%20you%20to%20depend%20on%20the%20source%20of%20that%20drop-down%20list%20in%20the%20logical%20test%20as%20shown%20in%20the%20below%20screenshot%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Logical%20Test.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F24982iD0F610BB5F22D684%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Logical%20Test.png%22%20alt%3D%22Logical%20Test.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20is%20the%20formula%3A%3C%2FP%3E%0A%3CPRE%3E%3DIF(F19%26lt%3B%26gt%3B%22%22%2CIF(OR(F19%3DA1%3AA16)%2CM19%2CL19*M19)%2C%22%22)%3C%2FPRE%3E%0A%3CP%3ETo%20enter%20it%2C%20press%20%3CSTRONG%3ECtrl%2BShift%2BEnter%3C%2FSTRONG%3E%20%3CSPAN%20class%3D%22%22%3Ebecause%20it's%20an%20array%20formula.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

I am using Excel 2013 and trying to create an IF forumula:

I have a drop down list of 32 items in Cell F9.  If they selection one of the first 16 I want to multiply Cell M9 by 1.  If they select one of the second 16 I want to multiply cell L9 by Cell M9.

 

I tried nesting them:

=IF(F9="Pre-Treat Asphalt",1*M9,IF(F9="Post-Treat Asphalt",1*M9,L9*M9)))

I also tried:

=IF(OR(F9="Pre-Treat Asphalt","Post-Treat Asphalt),"1*M9","L9*M9")

 

I'm not sure what I'm doing wrong. 

5 Replies

I advise you to depend on the source of that drop-down list in the logical test as shown in the below screenshot:

 

Logical Test.png

 

 

This is the formula:

=IF(F19<>"",IF(OR(F19=A1:A16),M19,L19*M19),"")

To enter it, press Ctrl+Shift+Enter because it's an array formula.

 

You are so Awesome!!!  Thank you so much!!!

Okay - it's not working completely.  Please see my attachment.  If the "Service Item" selected is O9:O24, then  "Subtotal" should equal the "Rate".  If the "Service Item" selected is O25:O41, then "Subtotal" should equal "Total Hours" times "Rate".

 

With this formula, Subtotal will equal Rate only if O9 is selected from the drop down menu for "Service Item".  All other "Service Item" selections (O10:O41) give a Subtotal of "Total Hours" times "Rate".

 

What happened is:

You forget to enter the formula by using the special keystroke shortcut: Ctrl+Shift+Enter.

 

Select cell N9, press F2 to activate the edit mode, then don't hit Enter, but press Ctrl+Shift+Enter simultaneously, and do this every time you activate the edit mode.

It's an array formula, you have to do this to force it to return the right result.

 

After that, drag the formula down, but before you drag it, you have to make the range absolute to prevent it from changing during the drag, so just replace this: O9:O24 with this: $O$9:$O$24.

 

Good luck

 

Given that your drop-down list source is in O9:O41 (which is 33 cells not 32), then you can use the MATCH function to return the position of your F9 selection within the source list.  If the position ios less than 17, then return whatever is in M9, otherwise return M9*L9.

=IF(MATCH(F9,$O$9:$O$41,0)<17,M9,M9*L9)

The 0 in the third argument of the MATCH function specifies an "exact match" which is OK because F9 must be selected from the list in $O$9:$O$41.