PDA

View Full Version : [SOLVED:] excel not multiplying correctly



NIMANIMA50
04-08-2022, 06:59 AM
Could someone please explain why Excel does not calculate the simple multipliaction correctly and return V=0 as a result of the sub.


Sub TEST()
Q = 3
P = 0.6
If Q * P = 1.8 Then V = 1 Else V = 0


End Sub

Paul_Hossler
04-08-2022, 07:48 AM
Probably due to floating point (Double) multiplication precision




Option Explicit


Sub TEST()
Dim Q As Double, P As Double, V As Double

Q = 3#
P = 0.6


If Round(Q * P, 1) = 1.8 Then
V = 1#
Else
V = 0#
End If


MsgBox V
End Sub

snb
04-08-2022, 09:43 AM
Sub TEST()
Q = 3
P = 0.6
v=0
If Format(Q * P, "fixed") = 1.8 Then v = 1

MsgBox v
End Sub
or

If Format(q * P) = "1.8" Then v = 1

NIMANIMA50
04-09-2022, 01:17 AM
Thank you Paul and SNB.

Aussiebear
04-09-2022, 02:58 AM
Thank you Paul and SNB.

What does that mean? Was it successful, Did it do what you requested? Have you found a solution to your issue? I for one am tired of the ambitious responses where people glib over but mean stuff all. Someone out there in the internet world has gone out of their way to share their knowledge and time to provide a solution to your issue. The Op gives a week inconsiderate response 'Thank you". Did you try the advice offered, what was the results? What didn't work? Its about engagement. If you post a thread or reply that generates a reply? To the people who seemed interested in your issue, did you give them enough information to maintain their interest?

NIMANIMA50
04-09-2022, 03:35 AM
What does that mean? Was it successful, Did it do what you requested? Have you found a solution to your issue? I for one am tired of the ambitious responses where people glib over but mean stuff all. Someone out there in the internet world has gone out of their way to share their knowledge and time to provide a solution to your issue. The Op gives a week inconsiderate response 'Thank you". Did you try the advice offered, what was the results? What didn't work? Its about engagement. id you post a thread or reply that generates a reply? To the people who seemed interested in your issue, did you give them enough information to maintain their interest?

Aussiebear, "thank you" means guestture of appreciation for those who spent time and effort to provide solution.
second, if the solutions provided were not addressing the issue (or not working) , there would be a follow up query.
third, instead of writing all these useless words , it was better to look at the question from another angle and offer other solution and prove your worth.
finally, I suggest that you make yourself more useful and find another way of getting noticed.

Paul_Hossler
04-09-2022, 04:17 AM
You're welcome, and thanks for the 'Thanks'. Many people don't acknowledge that a user or response was useful, or that someone took the time to read and suggest something


If a question asker is satisfied that the query is resolved, the unambiguous way is to use [Tread Tools] above the initial post and mark is as [SOLVED]


Doesn't mean that the thread is locked, and the same path can mark it as unsolved if it turns out there still is an issue

29602

NIMANIMA50
04-09-2022, 04:34 AM
Paul,
Thanks for the suggestion, i already marked it as [SOLVED] but i hope this will not make the post to other users that are willing to suggest other solutions to the question unavailable.

Paul_Hossler
04-09-2022, 04:40 AM
Doesn't mean that the thread is locked, and the same path can mark it as unsolved if it turns out there still is an issue

No, it's not Locked

Users can add and searches will find it

As an aside though, we find that many times it's better to start a new thread (possibly referencing the old one) instead of just tagging on to an old one

Aussiebear
04-09-2022, 04:32 PM
Aussiebear, "thank you" means guestture of appreciation for those who spent time and effort to provide solution....

How entertaining... however you have missed the mark again. It's the blandness of your response that I was questioning.

snb
04-10-2022, 01:56 AM
I can only second @Aussie.