Home

Formulas returning nonsensical results

%3CLINGO-SUB%20id%3D%22lingo-sub-674840%22%20slang%3D%22en-US%22%3EFormulas%20returning%20nonsensical%20results%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-674840%22%20slang%3D%22en-US%22%3E%3CP%3EI%20recently%20had%20a%20few%20formulas%20start%20returning%26nbsp%3Bnonsensical%20results%20and%20am%20at%20a%20total%20loss.%26nbsp%3B%20For%20example%2C%20a%20formula%20that%20takes%20the%20max%20of%20(0.095%2C%200.095%2C%200.2995%2C%200.2995)%20is%20returning%200.7787.%26nbsp%3B%20When%20I%20'F9'%20the%20max%20formula%20cell%20it%20returns%20the%20correct%20value.%26nbsp%3B%20I've%20attached%20screenshots%20showing%20this.%26nbsp%3B%20Has%20anybody%20else%20experienced%20this%20or%20know%20how%20to%20correct%20this%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20in%20advance%20for%20your%20help.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-674840%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-674851%22%20slang%3D%22en-US%22%3ERe%3A%20Formulas%20returning%20nonsensical%20results%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-674851%22%20slang%3D%22en-US%22%3E%3CP%3EAlso%2C%20yes%2C%20I've%20ensured%20that%20calculations%20are%20turned%20on.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-675041%22%20slang%3D%22en-US%22%3ERe%3A%20Formulas%20returning%20nonsensical%20results%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-675041%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F355874%22%20target%3D%22_blank%22%3E%40Excel_Building_Eng50%3C%2FA%3E%26nbsp%3B%2C%20do%20you%20mean%20under%20%22calculations%20turned%20on%22%20what%20they%20are%20in%20automatic%20mode%3F%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20258px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F117353i86C93E6B6C5CF87E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-675663%22%20slang%3D%22en-US%22%3ERe%3A%20Formulas%20returning%20nonsensical%20results%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-675663%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%2C%20yes%20calculations%20are%20automatic.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-675872%22%20slang%3D%22en-US%22%3ERe%3A%20Formulas%20returning%20nonsensical%20results%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-675872%22%20slang%3D%22en-US%22%3ECan%20you%20upload%20your%20file%20please%3F%20I'm%20unable%20to%20reproduce.%3CBR%20%2F%3E%3CBR%20%2F%3EYou%20might%20try%20the%20Evaluate%20Formula%20feature%20on%20the%20Formulas%20tab.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-675968%22%20slang%3D%22en-US%22%3ERe%3A%20Formulas%20returning%20nonsensical%20results%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-675968%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F19137%22%20target%3D%22_blank%22%3E%40Zack%20Barresse%3C%2FA%3E%26nbsp%3B%2C%20SS%20attached.%26nbsp%3B%20Error%20I%20previously%20mentioned%20is%20on%20sheet%20'CODE'.%26nbsp%3B%20A%20similar%20error%20is%20occurring%20on%20sheet%20'WEBHOLES'%20in%20cell%20F6.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-676173%22%20slang%3D%22en-US%22%3ERe%3A%20Formulas%20returning%20nonsensical%20results%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-676173%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F355874%22%20target%3D%22_blank%22%3E%40Excel_Building_Eng50%3C%2FA%3E%26nbsp%3B%2C%20as%20soon%20as%20I%20try%20to%20calculate%20something%20in%20this%20sheet%20(e.g.%20in%20any%20empty%20cell%20%3D1%2B2)%20it%20forwards%20me%20to%20VBA.%20It%20gives%20an%20error%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20397px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F117388iA9B334C501161CF9%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3Ebut%20that%20doesn't%20matter%2C%20I%20guess%20you%20have%20no%20such%20error.%20The%20point%20is%20your%20VBA%20code%20is%20involved%20into%20the%20sheet%20recalculation.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-676188%22%20slang%3D%22en-US%22%3ERe%3A%20Formulas%20returning%20nonsensical%20results%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-676188%22%20slang%3D%22en-US%22%3EThat%20doesn't%20have%20anything%20to%20do%20with%20the%20problem%2C%20although%20it%20should%20be%20addressed.%20There%20is%20only%20one%20Windows%20API%20reference%2C%20which%20is%20in%20module%20'Sub_GetBeamData'%3A%3CBR%20%2F%3E%3CBR%20%2F%3EDeclare%20Sub%20Sleep%20Lib%20%22kernel32%22%20(ByVal%20dwMilliseconds%20As%20Long)%3CBR%20%2F%3E%3CBR%20%2F%3EIt%20should%20be%20like%20this%3A%3CBR%20%2F%3E%23If%20VBA7%20Then%3CBR%20%2F%3EPrivate%20Declare%20PtrSafe%20Sub%20Sleep%20Lib%20%22kernel32%22%20(ByVal%20Milliseconds%20As%20LongPtr)%3CBR%20%2F%3E%23Else%3CBR%20%2F%3EPrivate%20Declare%20Sub%20Sleep%20Lib%20%22kernel32%22%20(ByVal%20Milliseconds%20As%20Long)%3CBR%20%2F%3E%23End%20If%3CBR%20%2F%3E%3CBR%20%2F%3EYou%20could%20wrap%20it%20in%20a%20function%2C%20such%20as%20the%20below%20code%2C%20assuming%20it's%20utilizing%20the%20above%20%5Bconditional%20compilation%5D%20code%20and%20resides%20in%20the%20same%20module%3A%3CBR%20%2F%3E%3CBR%20%2F%3EPublic%20Sub%20API_Sleep(ByVal%20Milliseconds%20As%20Long)%3CBR%20%2F%3ESleep%20Milliseconds%3CBR%20%2F%3EEnd%20Sub%3CBR%20%2F%3E%3CBR%20%2F%3EWe%20can%20use%20that%20conditional%20compilation%20because%20VBA7%20can%20accept%20ptr%20safe%2C%20which%20includes%2064%20bit%2C%20and%20previous%20to%20VBA7%20was%20only%2032%20bit.%20Full%20information%20on%20how%20it%20works%20can%20be%20found%20at%20the%20below%20link.%3CBR%20%2F%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fanswers.microsoft.com%2Fen-us%2Fmsoffice%2Fforum%2Fall%2Fthat-whacky-conditional-compiler-constant%2F3da810b8-9b89-4372-8104-a10c2ad25d4d%3Fauth%3D1%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fanswers.microsoft.com%2Fen-us%2Fmsoffice%2Fforum%2Fall%2Fthat-whacky-conditional-compiler-constant%2F3da810b8-9b89-4372-8104-a10c2ad25d4d%3Fauth%3D1%3C%2FA%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-676294%22%20slang%3D%22en-US%22%3ERe%3A%20Formulas%20returning%20nonsensical%20results%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-676294%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F19137%22%20target%3D%22_blank%22%3E%40Zack%20Barresse%3C%2FA%3E%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%2C%26nbsp%3B%20Thank%20you%20for%20point%20that%20out.%26nbsp%3B%20I've%20since%20removed%20the%20'Sleep'%20reference%20as%20we%20were%20not%20actually%20using%20it%20for%20anything.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAs%20expected%2C%20the%20cell%20formula%20problems%20persist.%26nbsp%3B%20Any%20further%20thoughts%20or%20findings%20on%20what%20might%20be%20the%20issue%20here%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20again!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-676310%22%20slang%3D%22en-US%22%3ERe%3A%20Formulas%20returning%20nonsensical%20results%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-676310%22%20slang%3D%22en-US%22%3EThere's%20several%20circular%20references.%20Since%20iterative%20calculations%20aren't%20turned%20on%2C%20I'm%20assuming%20this%20isn't%20desired.%20I've%20been%20tracing%20formula%20results%20which%2C%20when%20manually%20calculated%2C%20are%20returning%20a%20zero%20value.%20Some%20additional%20oddities%20is%20if%20you%20try%20ISNUMBER()%20on%20those%20specific%20cells%20you%20mentioned%20in%20your%20original%20post%2C%20it%20returns%20FALSE.%20Likewise%2C%20if%20you%20manually%20calculate%20those%20cells%2C%20they%20all%20return%20zero%20values%20as%20well.%20I'm%20not%20sure%20how%20long%20it%20will%20take%20me%20not%20being%20familiar%20with%20your%20model.%20Assuming%20for%20the%20moment%20that%20circular%20references%20are%20NOT%20desired%2C%20I'd%20recommend%20you%20pulling%20on%20that%20thread%20and%20tracing%20calculations%20back%20to%20where%20the%20circular%20reference%20originates%2C%20which%20you'd%20have%20the%20best%20luck%20finding%20as%20well.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-676355%22%20slang%3D%22en-US%22%3ERe%3A%20Formulas%20returning%20nonsensical%20results%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-676355%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F19137%22%20target%3D%22_blank%22%3E%40Zack%20Barresse%3C%2FA%3E%26nbsp%3B%2C%20Ah%20ok%20thanks%2C%20that%20makes%20sense.%26nbsp%3B%20This%20actually%20came%20about%20because%20we%20were%20trying%20to%20remove%20a%20circular%20reference%20that%20appeared%20to%20serve%20no%20purpose.%26nbsp%3B%20As%20I'm%20sure%20you've%20noticed%20this%20is%20a%20very%20old%20spreadsheet%2C%20and%20the%20originator%20is%20no%20longer%20with%20us%2C%20so%20we're%20still%20trying%20to%20get%20up%20to%20speed%20on%20the%20inner-workings.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-676359%22%20slang%3D%22en-US%22%3ERe%3A%20Formulas%20returning%20nonsensical%20results%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-676359%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F355874%22%20target%3D%22_blank%22%3E%40Excel_Building_Eng50%3C%2FA%3E%26nbsp%3Bquite%20the%20daunting%20task!%20The%20spreadsheet%20is%20fairly%20complex.%20Not%20being%20the%20creator%20will%20make%20it%20significantly%20more%20difficult.%20Although%20it%20might%20take%20more%20time%2C%20you%20might%20want%20to%20think%20about%20re-building%20it%20in%20portions%20and%20replicating%20as%20you%20go%2C%20ensuring%20the%20calculations%20are%20appropriate%20and%20efficient.%20I%20feel%20bad%20suggesting%20this%2C%20because%20with%20a%20model%20with%20this%20level%20of%20complexity%2C%20I%20certainly%20understand%20just%20how%20large%20of%20an%20undertaking%20that%20is.%20Or%2C%20probably%20what%20I%20would%20do%2C%20is%20take%20some%20time%20to%20become%20intimate%20with%20the%20current%20model%20and%20excise%20the%20circular%20reference.%20It%20would%20take%20someone%20with%20a%20lot%20of%20patience%20and%20understanding%20of%20your%20model%20but%20can%20certainly%20be%20done.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Excel_Building_Eng50
Occasional Contributor

I recently had a few formulas start returning nonsensical results and am at a total loss.  For example, a formula that takes the max of (0.095, 0.095, 0.2995, 0.2995) is returning 0.7787.  When I 'F9' the max formula cell it returns the correct value.  I've attached screenshots showing this.  Has anybody else experienced this or know how to correct this?

 

Thanks in advance for your help.

 

11 Replies

Also, yes, I've ensured that calculations are turned on.

@Excel_Building_Eng50 , do you mean under "calculations turned on" what they are in automatic mode?

image.png

 

@Sergei Baklan , yes calculations are automatic.

Can you upload your file please? I'm unable to reproduce.

You might try the Evaluate Formula feature on the Formulas tab.

@Zack Barresse , SS attached.  Error I previously mentioned is on sheet 'CODE'.  A similar error is occurring on sheet 'WEBHOLES' in cell F6.

@Excel_Building_Eng50 , as soon as I try to calculate something in this sheet (e.g. in any empty cell =1+2) it forwards me to VBA. It gives an error

image.png

but that doesn't matter, I guess you have no such error. The point is your VBA code is involved into the sheet recalculation.

That doesn't have anything to do with the problem, although it should be addressed. There is only one Windows API reference, which is in module 'Sub_GetBeamData':

Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

It should be like this:
#If VBA7 Then
Private Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal Milliseconds As LongPtr)
#Else
Private Declare Sub Sleep Lib "kernel32" (ByVal Milliseconds As Long)
#End If

You could wrap it in a function, such as the below code, assuming it's utilizing the above [conditional compilation] code and resides in the same module:

Public Sub API_Sleep(ByVal Milliseconds As Long)
Sleep Milliseconds
End Sub

We can use that conditional compilation because VBA7 can accept ptr safe, which includes 64 bit, and previous to VBA7 was only 32 bit. Full information on how it works can be found at the below link.

https://answers.microsoft.com/en-us/msoffice/forum/all/that-whacky-conditional-compiler-constant/3da...

@Zack Barresse @Sergei Baklan ,  Thank you for point that out.  I've since removed the 'Sleep' reference as we were not actually using it for anything.

 

As expected, the cell formula problems persist.  Any further thoughts or findings on what might be the issue here?

 

Thanks again!

 

 

 

There's several circular references. Since iterative calculations aren't turned on, I'm assuming this isn't desired. I've been tracing formula results which, when manually calculated, are returning a zero value. Some additional oddities is if you try ISNUMBER() on those specific cells you mentioned in your original post, it returns FALSE. Likewise, if you manually calculate those cells, they all return zero values as well. I'm not sure how long it will take me not being familiar with your model. Assuming for the moment that circular references are NOT desired, I'd recommend you pulling on that thread and tracing calculations back to where the circular reference originates, which you'd have the best luck finding as well.

@Zack Barresse , Ah ok thanks, that makes sense.  This actually came about because we were trying to remove a circular reference that appeared to serve no purpose.  As I'm sure you've noticed this is a very old spreadsheet, and the originator is no longer with us, so we're still trying to get up to speed on the inner-workings.

@Excel_Building_Eng50 quite the daunting task! The spreadsheet is fairly complex. Not being the creator will make it significantly more difficult. Although it might take more time, you might want to think about re-building it in portions and replicating as you go, ensuring the calculations are appropriate and efficient. I feel bad suggesting this, because with a model with this level of complexity, I certainly understand just how large of an undertaking that is. Or, probably what I would do, is take some time to become intimate with the current model and excise the circular reference. It would take someone with a lot of patience and understanding of your model but can certainly be done.

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
46 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
30 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
13 Replies