SUMM with gHOST!!!!

User avatar
sal21
PlatinumLounger
Posts: 4370
Joined: 26 Apr 2010, 17:36

SUMM with gHOST!!!!

Post by sal21 »

peraphs Hans just have post a solution for the prob in image, but i dont found...

in effect in debug print the 2 var are exactlly the same but th IF statement not WORK!!!!!!!!!!!!

note:
all var are dimensioned Double
Last edited by sal21 on 08 Nov 2013, 10:36, edited 1 time in total.

User avatar
HansV
Administrator
Posts: 78629
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: SUMM with gHOST!!!!

Post by HansV »

What happens if you use

Debug.Print DIFFERENZA - SALDO

Do you get 0?
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4370
Joined: 26 Apr 2010, 17:36

Re: SUMM with gHOST!!!!

Post by sal21 »

HansV wrote:What happens if you use

Debug.Print DIFFERENZA - SALDO

Do you get 0?

-3,63797880709171E-12 (??????????????????)

User avatar
HansV
Administrator
Posts: 78629
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: SUMM with gHOST!!!!

Post by HansV »

That means that DIFFERENZA and SALDO are almost equal but not quite: there is a difference of 0.0000000000036...
Change the line

If DIFFERENZA <> SALDO Then

to

If Abs(DIFFERENZA - SALDO) > 0.0001 Then

The code will then ignore very small differences between DIFFERENZA and SALDO.
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4370
Joined: 26 Apr 2010, 17:36

Re: SUMM with gHOST!!!!

Post by sal21 »

HansV wrote:That means that DIFFERENZA and SALDO are almost equal but not quite: there is a difference of 0.0000000000036...
Change the line

If DIFFERENZA <> SALDO Then

to

If Abs(DIFFERENZA - SALDO) > 0.0001 Then

The code will then ignore very small differences between DIFFERENZA and SALDO.
work tkx!