View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Vergel Adriano Vergel Adriano is offline
external usenet poster
 
Posts: 857
Default decimal places????

Parkin_m,

Use the Format Function in VBA

Sub test()
Dim a As Variant

a = 54.3
MsgBox Format(a, "0.00")
End Sub


If you're expecting to see the formatted value in the worksheet, then you'll
need to format the cell.

Sub test2()
Dim a As Variant
a = 54.3
With ActiveSheet.Range("A1")
.Value = a
.NumberFormat = "0.00"
End With

End Sub


--
Hope that helps.

Vergel Adriano


"parkin_m" wrote:

I have a numbers saved in a variable of Variant type.

The numbers are 54, 54.3, 55.54. How do i change these into 54.00, 54.30,
55.54? (Is there a function I can use?)

Thanks in advance
--
--
Thanks

Parkin_m