Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default decimal places????

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Decimal places Tricia Excel Worksheet Functions 2 October 27th 08 03:14 AM
Subtracting two 2-decimal place numbers gives result 13-decimal places? [email protected] Excel Worksheet Functions 5 March 12th 07 10:38 PM
Decimal Places Rab Swinney Excel Discussion (Misc queries) 5 January 10th 07 07:01 PM
FIXED 2 DECIMAL PLACES, MUST ENTER ALL ZEROES AFTER DECIMAL POINT. SUKYKITTY Excel Discussion (Misc queries) 3 July 6th 05 01:50 PM
decimal places HB Excel Discussion (Misc queries) 4 March 15th 05 02:19 AM


All times are GMT +1. The time now is 12:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"