Help with a formula

%3CLINGO-SUB%20id%3D%22lingo-sub-2623329%22%20slang%3D%22en-US%22%3EHelp%20with%20a%20formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2623329%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20a%20spreadsheet%20that%20calculates%20the%20total%20price%20of%20various%20optional%20items%20associated%20with%20building%20a%20new%20home.%20For%20each%20item%20on%20the%20very%20long%20list%20I%20have%20a%20cell%20that%20acts%20as%20a%20checkbox.%20The%20valid%20entries%20in%20the%20check%20box%20are%20%22n%22%20(I%20don't%20want%20it)%2C%20%22%3F%22%20(I%20need%20more%20information%20before%20deciding)%2C%20%22y%22%20if%20I%20do%20want%201%20of%20the%20associated%20item%20or%20a%20numeric%20entry%20greater%20than%201%20if%20I%20want%20more%20than%201%20of%20a%20particular%20item.%20The%20formula%20in%20cell%20F2%20in%20the%20attached%20sheet%20for%20extending%20the%20cost%20for%20an%20item%20in%20row%202%20that%20I%20want%20is%20as%20follows%3A%26nbsp%3B%3DIF(OR(B2%3D%22y%22%2CB2%26gt%3B0)%2CIF(B2%3D%22y%22%2CD2%2CD2*B2)%2C%22%22).%20It%20properly%20calculates%20the%20extended%20price%20for%20an%20item%20if%20I%20enter%20either%20%22y%22%20or%20a%20specific%20quantity%20greater%20than%201%20in%20cell%20B2.%20But%20if%20I%20enter%20anything%20else%2C%20e.g.%20a%20%22n%22%2C%20in%20the%20checkbox%2C%20I%20get%20a%20%23VALUE!%20error%3B%20I%20want%20the%20cell%20to%20be%20blank.%20I%20can%20get%20rid%20of%20that%20error%20by%20modifying%20the%20formula%20as%20I%20have%20done%20in%20cell%20F3%20with%20IFERROR%2C%20like%20this%3A%26nbsp%3B%3DIFERROR(IF(OR(B3%3D%22y%22%2CB3%26gt%3B0)%2CIF(B3%3D%22y%22%2CD3%2CD3*B3)%2C%22%22)%2C%22%22)%20as%20shown%20in%20cell%20F3.%20But%20I'd%20really%20like%20to%20know%20what%20is%20wrong%20with%20my%20original%20version.%20Any%20ideas%20folks%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2623329%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-2623348%22%20slang%3D%22en-US%22%3ERe%3A%20Help%20with%20a%20formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2623348%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1122186%22%20target%3D%22_blank%22%3E%40djshaw63%3C%2FA%3E%26nbsp%3BI%20would%20like%20to%20suggest%20that%20you%20change%20the%20set-up%20slightly.%20Rather%20than%20having%20a%20cell%20to%20be%20%22y%22%20or%20a%20number%2C%20why%20not%20have%20one%20column%20for%20y%2C%20n%20or%20%3F%20%26nbsp%3Band%20one%20where%20you%20fill%20in%20the%20qty.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThen%20use%20a%20formula%20that%20checks%20tests%20column%20B%20for%20%22y%22%20(True%3D1%2C%20False%3D0)%20X%20qyt%20X%20Unit%20cost.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESee%20attached.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2623407%22%20slang%3D%22en-US%22%3ERe%3A%20Help%20with%20a%20formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2623407%22%20slang%3D%22en-US%22%3EThanks!%20I%20like%20that%20idea.%20I%20also%20considered%20not%20using%20a%20%22y%22%20at%20all%20but%20just%20a%20numeric%20value%20%26gt%3B%200%20if%20I%20wanted%20that%20option%20at%20all.%20But%20as%20a%20very%20long%20time%20Excel%20user%20(since%20Multiplan%20on%20the%20Mac%20in%20'84)%2C%20I%20am%20just%20very%20frustrated%20that%20I%20can't%20figure%20out%20why%20my%20present%20formula%20generates%20the%20%23VALUE!%20error.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2623424%22%20slang%3D%22en-US%22%3ERe%3A%20Help%20with%20a%20formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2623424%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1122186%22%20target%3D%22_blank%22%3E%40djshaw63%3C%2FA%3E%26nbsp%3BWell%2C%20that's%20because%20%22n%22%20is%20greater%20than%20zero.%20So%2C%20even%20when%20you%20have%20%22n%22%20in%20column%20B%2C%20the%20first%20argument%20will%20return%20TRUE.%20Than%20the%20next%20argument%20is%20evaluated%26nbsp%3B%3CSTRONG%3E%3CEM%3EIF(B3%3D%22y%22%2CD3%2CD3*B3)%3C%2FEM%3E%3C%2FSTRONG%3E%20.%20Since%20B3%20does%20not%20contain%20%22y%22%2C%20Excel%20executes%20the%20calculation%20D3*B3%20which%20returns%20the%20%23VALUE%20error%20as%20you%20can't%20multiply%20a%20number%20by%20a%20text.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

I have a spreadsheet that calculates the total price of various optional items associated with building a new home. For each item on the very long list I have a cell that acts as a checkbox. The valid entries in the check box are "n" (I don't want it), "?" (I need more information before deciding), "y" if I do want 1 of the associated item or a numeric entry greater than 1 if I want more than 1 of a particular item. The formula in cell F2 in the attached sheet for extending the cost for an item in row 2 that I want is as follows: =IF(OR(B2="y",B2>0),IF(B2="y",D2,D2*B2),""). It properly calculates the extended price for an item if I enter either "y" or a specific quantity greater than 1 in cell B2. But if I enter anything else, e.g. a "n", in the checkbox, I get a #VALUE! error; I want the cell to be blank. I can get rid of that error by modifying the formula as I have done in cell F3 with IFERROR, like this: =IFERROR(IF(OR(B3="y",B3>0),IF(B3="y",D3,D3*B3),""),"") as shown in cell F3. But I'd really like to know what is wrong with my original version. Any ideas folks?

 

6 Replies

@djshaw63 I would like to suggest that you change the set-up slightly. Rather than having a cell to be "y" or a number, why not have one column for y, n or ?  and one where you fill in the qty.

 

Then use a formula that checks tests column B for "y" (True=1, False=0) X qyt X Unit cost.

 

See attached.

Thanks! I like that idea. I also considered not using a "y" at all but just a numeric value > 0 if I wanted that option at all. But as a very long time Excel user (since Multiplan on the Mac in '84), I am just very frustrated that I can't figure out why my present formula generates the #VALUE! error.

@djshaw63 Well, that's because "n" is greater than zero. So, even when you have "n" in column B, the first argument will return TRUE. Than the next argument is evaluated IF(B3="y",D3,D3*B3) . Since B3 does not contain "y", Excel executes the calculation D3*B3 which returns the #VALUE error as you can't multiply a number by a text.

 

  • Ah HA!! That surely explains it. Never knew that a text value is evaluated as greater than 0. So I will use your suggested additional cell with a numeric value that will be invoked if the checkbox contains a "y". MANY THANKS Riny!!

@djshaw63 You could use it this way:

=IF(OR(B3="y",ISNUMBER(B3)),IF(B3="y",D3,D3*B3),"")

Assuming that you will never enter a negative quantity. 

I like that too!