Forum Discussion
Excel_Building_Eng50
Jun 06, 2019Copper Contributor
Formulas returning nonsensical results
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...
Zack Barresse
Jun 06, 2019Iron Contributor
Can you upload your file please? I'm unable to reproduce.
You might try the Evaluate Formula feature on the Formulas tab.
You might try the Evaluate Formula feature on the Formulas tab.
Excel_Building_Eng50
Jun 06, 2019Copper Contributor
Zack Barresse , SS attached. Error I previously mentioned is on sheet 'CODE'. A similar error is occurring on sheet 'WEBHOLES' in cell F6.
- SergeiBaklanJun 06, 2019Diamond Contributor
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
but that doesn't matter, I guess you have no such error. The point is your VBA code is involved into the sheet recalculation.
- Zack BarresseJun 06, 2019Iron ContributorThat 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/3da810b8-9b89-4372-8104-a10c2ad25d4d?auth=1- Excel_Building_Eng50Jun 06, 2019Copper Contributor
Zack Barresse SergeiBaklan , 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!