View Full Version : Solved: Format Number
Kindly_Kaela
02-21-2007, 08:58 AM
Hi,
What is the proper code to format variable numbers with a comma (ie: 1,000), decimals (ie: 10.00) and dollar sign (ie: $10.00).
Thank you!
Kaela
:cloud9:
lucas
02-21-2007, 09:48 AM
from a userform to the document?
Zephid15
02-21-2007, 09:56 AM
FormatCurrency works for well... just currency
txt1.value=FormatCurrency(data(1,1))
lucas
02-21-2007, 09:57 AM
Look up " User-Defined Numeric Formats (Format Function)" in VBE Help....Not regular help but in the visual basic editor help.
fumei
02-21-2007, 02:55 PM
That is a good suggestion.
Kindly_Kaela
02-22-2007, 08:57 AM
FormatCurrency works for well... just currency
txt1.value=FormatCurrency(data(1,1))
Zephid, what did I do wrong? Error 13, type mismatch.
Public Sub TestDollar()
UnitPrice = 60
Selection.TypeText Text:=FormatCurrency(UnitPrice(1,1))
End Sub
Kindly_Kaela
02-22-2007, 09:03 AM
Thanks Steve, that was a great suggestion. Here's what I came up with...
Sub pricetest()
Dim priceText As String
Dim totalPrice As Single
totalPrice = 9.6888
priceText = Format(totalPrice, "$#,##0.00;($#,##0.00)")
Selection.TypeText Text:=priceText
End Sub
lucas
02-22-2007, 09:36 AM
That looks like it works just fine...glad you got it hashed out. Don't forget to mark your thread solved.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.