View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\) Rick Rothstein \(MVP - VB\) is offline
external usenet poster
 
Posts: 2,202
Default VBA Sum returns Wrong Format

Well, I must say, I am surprised that worked. On the VBA side of things, the
Currency data type does not contain the currency symbol or nor the thousands
separator (which can be seen by adding a Debug.Print MySum statement to the
subroutine).

While I am sure what you posted will do what the OP probably actually
wanted, I would note that answers using your Dim statement will not be the
same as those produced but the OP's original code. His Dim'ming the MySum
variable as Integer would mean no decimal dollars are returned to the
worksheet whereas your Currency data type will do so.

Rick


"JLGWhiz" wrote in message
...
Dim MySum As Currency

"code_hungry" wrote:

If Anyone could give me a hand....

Cell E33 value is "$2,793.70"
Cell F33 value is "$450.00"
My code rounds up the result and returns the value 3244. I need the
value
to be but I need it "3,243.70"

What do I have to change in the code below?

Thanks

Sub sum()
Dim MySum As Integer
Dim MyRange As Range

Set MyRange = ActiveSheet.Range("E33:F33")
MySum = Application.WorksheetFunction.sum(MyRange)
Range("F46").Value = MySum

End Sub
--