View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Keith R[_2_] Keith R[_2_] is offline
external usenet poster
 
Posts: 37
Default VBA Sum returns Wrong Format

If you are always going to use F46 as your destination cell, the simple
option is simply to format that cell.

If your code may dynamically place results in difference cells and you need
to format within VBA then the following might work for you. I suggest when
it comes to things that you can do manually but are trying to replicate in
code, use the macro recorder to give you a push in the right direction-
that's where this code comes from. Either select the cell in code, or change
the select statement to reflect your target range.

Selection.NumberFormat = "#,##0.00"

HTH,
Keith

"code_hungry" wrote in message
...
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
--