Qingping Cheng


Hi All,

I got a probelm with Excel VBA. I have a range named as "MyRange" with currency data. I would like to add up all currency numbers in the range. I used the following codes:

Dim MyRange

Dim MyCurrency

MyRange=Range("A1:A3")

MyCurrency=Application.WorksheetFunction.Sum(MyRange)

MyCurrency returns only 0 whatever currency values in MyRange.

Please help and thanks in advance

Qingping





Re: WoksheetFunction Doesn't Work With Currency Range

Andy Pope


Hi,

Does the cell contain a value formatted as currency or a textual representation of the currency value.
i.e.

1.23 formatted to display as $1.23

or

$1.23

If it is the latter then the cells will be treated as text and therefore sum to zero.
You would need to convert the text to real values, either in a set of helper cells or via code.






Re: WoksheetFunction Doesn't Work With Currency Range

Qingping Cheng

Thank you Andy. It is the latter and the problem has been solved after converting text to column.