Calculations in different countries

G

Guest

I have a macro that is used by people in the US and in
Germany. The macro adds columns to check total debits vs.
total credits.

When I run it in the US, it works fine because it sees
50.25. But when the macro runs for one of the German
users, it sees 50,25 and it doesn't use the 25 in
calculating the total.

The reason for the difference is in this line of code:

TotalDebits = TotalDebits + Val(ActiveCell.Offset(0, 5))

According to Help: "The Val function recognizes only the
period (.) as a valid decimal separator. When different
decimal separators are used, as in international
applications, use CDbl instead to convert a string to a
number."

How do I use CDbl in the offending line of code?
Thanks.
 
M

michdenis

Try this,


TotalDebits = TotalDebits + Val(Replace(ActiveCell.Offset(0, 5), ",", "."))


Salutations!


<[email protected]> a écrit dans le message de I have a macro that is used by people in the US and in
Germany. The macro adds columns to check total debits vs.
total credits.

When I run it in the US, it works fine because it sees
50.25. But when the macro runs for one of the German
users, it sees 50,25 and it doesn't use the 25 in
calculating the total.

The reason for the difference is in this line of code:

TotalDebits = TotalDebits + Val(ActiveCell.Offset(0, 5))

According to Help: "The Val function recognizes only the
period (.) as a valid decimal separator. When different
decimal separators are used, as in international
applications, use CDbl instead to convert a string to a
number."

How do I use CDbl in the offending line of code?
Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top