SOLVED

IF Function

%3CLINGO-SUB%20id%3D%22lingo-sub-2275986%22%20slang%3D%22en-US%22%3EIF%20Function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2275986%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20trying%20to%20create%20a%20function%20to%20calculate%20the%20number%20of%20each%20cake%20flavor%20needed.%3CBR%20%2F%3E%3CBR%20%2F%3EThis%20is%20what%20I%20was%20trying%20to%20input%20into%20P2%20but%20got%20a%20NAME%20error%3A%26nbsp%3B%3CSPAN%3E%3DIF(J2%3D%E2%80%9DVanilla%E2%80%9D%2CL2%2C%22%22)%3C%2FSPAN%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22CottageCelebrations_1-1618581765323.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F273339iBD90F7869C51D0E5%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22CottageCelebrations_1-1618581765323.png%22%20alt%3D%22CottageCelebrations_1-1618581765323.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EI%20was%20also%20planning%20to%20do%20this%20with%20each%20flavor%20in%20%3CA%20href%3D%22mailto%3AQ%40%2C%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EQ2%2C%3C%2FA%3E%26nbsp%3BR2%2C%20S2%2C%20and%20T2.%3CBR%20%2F%3E%3CBR%20%2F%3ENote%2C%20the%20numbers%20showing%20now%20are%20what%20I%20manually%20entered%20but%20wanted%20to%20show%20you%20what%20the%20end%20goal%20was.%26nbsp%3B%20Thank%20you!%3CBR%20%2F%3E%3CBR%20%2F%3EPC%2FWin%2010%20Excel%20365%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2275986%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2276783%22%20slang%3D%22en-US%22%3ERe%3A%20IF%20Function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2276783%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1028376%22%20target%3D%22_blank%22%3E%40CottageCelebrations%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20a%20comment%2C%20based%20on%20screenshot%20only%2C%20especially%20if%20it%20doesn't%20show%20what%20is%20in%20formula%20bar%2C%20quit%20often%20it's%20hard%20to%20understand%20what%20is%20the%20actual%20reason%20of%20the%20error.%20On%20this%20site%20we%20may%20only%20make%20some%20guesses.%20Hans%20indicated%20two%20possible%20reasons%20-%20wrong%20quotes%20and%20in%20your%20locale%20you%20shall%20use%20semicolons%20instead%20of%20commas.%20One%20of%20them%20works.%3C%2FP%3E%0A%3CP%3EBottom%20line%20-%20it's%20always%20better%20to%20provide%20small%20sample%20file%20which%20illustrates%20an%20issue.%20Answers%20will%20be%20more%20exact%20and%20received%20more%20fast.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2276631%22%20slang%3D%22en-US%22%3ERe%3A%20IF%20Function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2276631%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%2C%20I%20tried%20yours%20too%20and%20the%20first%20one%20worked%20but%20the%20second%20formula%20filled%20the%20cell%20with%20the%20formula%2C%20not%20the%20number.%26nbsp%3B%20I%20tried%20formatting%20the%20cell%20as%20a%20number%20and%20checking%20the%20box%20with%20the%20comma%20but%20didn't%20help.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2276223%22%20slang%3D%22en-US%22%3ERe%3A%20IF%20Function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2276223%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1639%22%20target%3D%22_blank%22%3E%40Detlef%20Lewin%3C%2FA%3E%26nbsp%3Bthank%20you!%20it%20worked!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2276041%22%20slang%3D%22en-US%22%3ERe%3A%20IF%20Function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2276041%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1028376%22%20target%3D%22_blank%22%3E%40CottageCelebrations%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20are%20using%20the%20wrong%20quote%20signs%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%3DIF(J2%3D%22Vanilla%22%2CL2%2C%22%22)%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2276038%22%20slang%3D%22en-US%22%3ERe%3A%20IF%20Function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2276038%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1028376%22%20target%3D%22_blank%22%3E%40CottageCelebrations%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20P2%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3DIF(%24J2%3DP%241%2C%24L2%2C%22%22)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20use%20comma%20as%20decimal%20separator%2C%20it%20should%20be%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3DIF(%24J2%3DP%241%24L2%3B%22%22)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFill%20down%2C%20then%20to%20the%20right%20(or%20vice%20versa).%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

I am trying to create a function to calculate the number of each cake flavor needed.

This is what I was trying to input into P2 but got a NAME error: =IF(J2=”Vanilla”,L2,"")

CottageCelebrations_1-1618581765323.png


I was also planning to do this with each flavor in Q2, R2, S2, and T2.

Note, the numbers showing now are what I manually entered but wanted to show you what the end goal was.  Thank you!

PC/Win 10 Excel 365

5 Replies

@CottageCelebrations 

In P2:

 

=IF($J2=P$1,$L2,"")

 

If you use comma as decimal separator, it should be

 

=IF($J2=P$1$L2;"")

 

Fill down, then to the right (or vice versa).

best response confirmed by CottageCelebrations (New Contributor)
Solution

@CottageCelebrations 

You are using the wrong quote signs:

=IF(J2="Vanilla",L2,"")

@Detlef Lewin thank you! it worked!

Thanks, I tried yours too and the first one worked but the second formula filled the cell with the formula, not the number.  I tried formatting the cell as a number and checking the box with the comma but didn't help.

 

@CottageCelebrations 

As a comment, based on screenshot only, especially if it doesn't show what is in formula bar, quit often it's hard to understand what is the actual reason of the error. On this site we may only make some guesses. Hans indicated two possible reasons - wrong quotes and in your locale you shall use semicolons instead of commas. One of them works.

Bottom line - it's always better to provide small sample file which illustrates an issue. Answers will be more exact and received more fast.