Data validation not functioning the same as a test formula

%3CLINGO-SUB%20id%3D%22lingo-sub-1387978%22%20slang%3D%22en-US%22%3EData%20validation%20not%20functioning%20the%20same%20as%20a%20test%20formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1387978%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20a%20puzzling%20situation%20on%20Data%20Validation.%20I%20have%20a%20formula%20to%20test%20the%20contents%20of%20two%20cells%20against%20each%20other%20and%20against%20other%20criteria.%20When%20I%20test%20the%20formula%20outside%20of%20data%20validation%20it%20responds%20as%20expected%20to%20changes%20in%20the%20data%20cells.%20BUT%20when%20I%20copy%20that%20formula%20into%20the%20data%20validation%20for%20the%20cell%20involved%20it%20fails%20to%20perform%20as%20expected.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20two%20cells%20are%20Budget%20Amount%20and%20Actual%20Amount.%20If%20Budget%20Amount%20is%20blank%20I%20simply%20test%20the%20Actual%20Amount%20to%20make%20sure%20there%20are%20only%202%20decimal%20places%20to%20the%20right%20of%20the%20dot.%26nbsp%3B%3C%2FP%3E%3CP%3EIf%2C%20however%2C%20the%20Budget%20has%20a%20value%20in%20it%20I%20test%20to%20see%20if%20the%20Actual%20Amount%20is%20equal%20to%20the%20Budget%20Amount%20and%20then%20test%20for%20decimal%20places%20to%20the%20right.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBelow%20is%20my%20formula%20where%20CA%20is%20the%20Budgeted%20Amount%20and%20CB%20is%20the%20Actual%20Amount.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DIF(OR(AND(CA14%3D%22%22%2CCB14*100-INT(CB14*100)%3D0)%2CAND(CA14%3DCB14%2CCB14*100-INT(CB14*100)%3D0))%2C1%2C0)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20formula%20works%20100%25%20of%20the%20time%20when%20tested%20external%20to%20the%20Data%20Validation%20BUT%20fails%20every%20time%20that%20the%20Budgeted%20Amount%20cell%20is%20empty%20(Blank)%20and%20the%20Actual%20Amount%20has%20more%20than%202%20decimal%20places%20when%20used%20as%20a%20formula%20in%20Data%20Validation%3C%2FP%3E%3CP%3E.%3C%2FP%3E%3CP%3EAny%20suggestions%20would%20be%20appreciated.%20I'm%20out%20of%20ideas.%20(BTW%2C%20Tried%20MOD%20but%20it%20is%20too%20quirky%20to%20rely%20on).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETheOldPuterMan%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1387978%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-1394908%22%20slang%3D%22en-US%22%3ERe%3A%20Data%20validation%20not%20functioning%20the%20same%20as%20a%20test%20formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1394908%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F317593%22%20target%3D%22_blank%22%3E%40TheOldPuterMan%3C%2FA%3E%26nbsp%3BNot%20sure%20what%20you%20try%20to%20achieve.%20When%20I%20break%20down%20the%20formula%20I%20understand%20the%20following.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EAND(CA14%3D%22%22%2CCB14*100-INT(CB14*100)%3D0)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EThis%20will%20return%20TRUE%20if%20CA%20is%20empty%20%3CSTRONG%3E%3CFONT%20color%3D%22%23FF0000%22%3Eand%3C%2FFONT%3E%3C%2FSTRONG%3E%20CB%20has%20up%20to%20two%20(i.e.%200%2C1%20or%202)%20decimals.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EAND(CA14%3DCB14%2CCB14*100-INT(CB14*100)%3D0)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EThis%20will%20return%20TRUE%20if%20CA%20is%20equal%20to%20CB%26nbsp%3B%3CSTRONG%3E%3CFONT%20color%3D%22%23FF0000%22%3Eand%3C%2FFONT%3E%3C%2FSTRONG%3E%20CB%20has%20up%20to%20two%20(i.e.%200%2C1%20or%202)%20decimals.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOverall%2C%20the%20formula%20returns%201%20if%20either%20of%20the%20two%20above%20are%20TRUE%2C%20otherwise%20it%20returns%200.%20Is%20this%20what%20you%20intend%20to%20achieve%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20issue%20that%20remains%20is%20that%20you%20want%20to%20use%20this%20in%20a%20formula%20within%20Data%20Validation%20(DV).%20I%20pasted%20the%20exact%20formula%20into%20a%20custom%20DV%20rule%20and%20it%20would%20allow%20everything%20when%20CA%20was%20empty.%20When%20CA%20was%20not%20empty%20it%20only%20allowed%20me%20to%20enter%20the%20exact%20same%20number%20in%20CB%2C%20but%20only%20if%20it%20did%20not%20have%20more%20than%20two%20decimals.%20This%20doesn't%20make%20any%20sense%20to%20me.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENow%2C%20you%20could%20enter%20the%20following%20formula%20in%20a%20custom%20DV%20rule.%20It%20will%20allow%20any%20number%20with%20up%20to%20two%20decimals%2C%20irrespective%20what's%20in%20CA.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DISNUMBER(CB14)*(LEN(CB14)-IFERROR(FIND(%22.%22%2CCB14)%2CLEN(CB14))%26lt%3B%3D2)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20your%20actual%20numbers%20are%20picked%20up%20by%20a%20formula%2C%20rather%20than%20by%20direct%20input%20in%20CB%2C%20you%20could%20wrap%20that%20formula%20in%20a%20ROUND%20function%20that%20rounds%20all%20numbers%20to%202%20decimals).%20Then%20there%20is%20no%20need%20for%20DV%20doing%20the%20testing%20for%20you.%26nbsp%3BBut%20perhaps%20I'm%20missing%20the%20point%20completely%20here.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Contributor

I have a puzzling situation on Data Validation. I have a formula to test the contents of two cells against each other and against other criteria. When I test the formula outside of data validation it responds as expected to changes in the data cells. BUT when I copy that formula into the data validation for the cell involved it fails to perform as expected.

 

The two cells are Budget Amount and Actual Amount. If Budget Amount is blank I simply test the Actual Amount to make sure there are only 2 decimal places to the right of the dot. 

If, however, the Budget has a value in it I test to see if the Actual Amount is equal to the Budget Amount and then test for decimal places to the right.

 

Below is my formula where CA is the Budgeted Amount and CB is the Actual Amount.

 

=IF(OR(AND(CA14="",CB14*100-INT(CB14*100)=0),AND(CA14=CB14,CB14*100-INT(CB14*100)=0)),1,0)

 

This formula works 100% of the time when tested external to the Data Validation BUT fails every time that the Budgeted Amount cell is empty (Blank) and the Actual Amount has more than 2 decimal places when used as a formula in Data Validation

.

Any suggestions would be appreciated. I'm out of ideas. (BTW, Tried MOD but it is too quirky to rely on).

 

Thanks,

 

TheOldPuterMan

1 Reply
Highlighted

@TheOldPuterMan Not sure what you try to achieve. When I break down the formula I understand the following.

 

AND(CA14="",CB14*100-INT(CB14*100)=0)

This will return TRUE if CA is empty and CB has up to two (i.e. 0,1 or 2) decimals.

 

AND(CA14=CB14,CB14*100-INT(CB14*100)=0)

This will return TRUE if CA is equal to CB and CB has up to two (i.e. 0,1 or 2) decimals.

 

Overall, the formula returns 1 if either of the two above are TRUE, otherwise it returns 0. Is this what you intend to achieve?

 

The issue that remains is that you want to use this in a formula within Data Validation (DV). I pasted the exact formula into a custom DV rule and it would allow everything when CA was empty. When CA was not empty it only allowed me to enter the exact same number in CB, but only if it did not have more than two decimals. This doesn't make any sense to me.

 

Now, you could enter the following formula in a custom DV rule. It will allow any number with up to two decimals, irrespective what's in CA.

 

=ISNUMBER(CB14)*(LEN(CB14)-IFERROR(FIND(".",CB14),LEN(CB14))<=2)

 

If your actual numbers are picked up by a formula, rather than by direct input in CB, you could wrap that formula in a ROUND function that rounds all numbers to 2 decimals). Then there is no need for DV doing the testing for you. But perhaps I'm missing the point completely here.