Evaluate error?

adulador

New Member
Joined
Mar 19, 2012
Messages
16
Hi,

I'm running the evaluate vba function.

Sub Test1()
Dim dbValue As Double
dbValue = 3.1415
MsgBox Evaluate("SIN(" & dbValue & ")")
End Sub

Sub Test2()
Dim dbValue As Double
dbValue = 3
MsgBox Evaluate("SIN(" & dbValue & ")")
End Sub

The first does not work, but the second does. It's not because of Pi, it's because of floating point. If dbValue, instead of 3.1415, has a value of 1, it works, but 1.1 is not working, neither 1.2, nor 1.2345678,... only integers.

Any idea?

Kind Regards
 
That is because your System/Excel/VBA language configuration are "syncronised" to what it should be.
In other PC default configurations (Spanish, and I suppose all latinamerican), I "predict" it would crash, because VBA does not change the decimal separator between (but System and Excel do).

In order to not get an error with the eval function any spanish/whatever should change the decimal configuration to English default. As soon as I did it, worked flawlessly, so, the problem was there.
 
Upvote 0

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top