decimal places????

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 

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

Back
Top