ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   formatting a variable (https://www.excelbanter.com/excel-programming/367828-formatting-variable.html)

dstiefe

formatting a variable
 
Is there anyway to formatt a variable?

so instead of seeing:
x = 10000

the variable ='s
x = 10,000

Thank you

Kevin B

formatting a variable
 
Use the Format() function

Format(varName,"$#,##0.00") or Format(varName,"#,##0.00")

The # symbol in the mask meansif there's a value at this position,
display/print it, otherwise leave blank, while the 0 in the format mask means
if there is no value at this position, place as 0.


--
Kevin Backmann


"dstiefe" wrote:

Is there anyway to formatt a variable?

so instead of seeing:
x = 10000

the variable ='s
x = 10,000

Thank you


dstiefe

formatting a variable
 
I'm getting a compile error when I use the ( )?

"Kevin B" wrote:

Use the Format() function

Format(varName,"$#,##0.00") or Format(varName,"#,##0.00")

The # symbol in the mask meansif there's a value at this position,
display/print it, otherwise leave blank, while the 0 in the format mask means
if there is no value at this position, place as 0.


--
Kevin Backmann


"dstiefe" wrote:

Is there anyway to formatt a variable?

so instead of seeing:
x = 10000

the variable ='s
x = 10,000

Thank you


JNW

formatting a variable
 
The parenthesis are needed when there is a condition involved. i.e. x =
format(x,"$#,##0.00").
--
JNW


"dstiefe" wrote:

I'm getting a compile error when I use the ( )?

"Kevin B" wrote:

Use the Format() function

Format(varName,"$#,##0.00") or Format(varName,"#,##0.00")

The # symbol in the mask meansif there's a value at this position,
display/print it, otherwise leave blank, while the 0 in the format mask means
if there is no value at this position, place as 0.


--
Kevin Backmann


"dstiefe" wrote:

Is there anyway to formatt a variable?

so instead of seeing:
x = 10000

the variable ='s
x = 10,000

Thank you



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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com