Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel 97, Format Number Question

Status
Not open for further replies.

kelqc

Programmer
Feb 16, 2003
31
AU
Hi

I want to set the decimal places for the number 123.45678

I know I can use format(123.45678,"##0.00") to get 123.46

But I want to be able to change the decimal format at run time, so can you change the "##0.00" string to a number variable eg

format(123.45678, 2) to get 123.45

Thanks

Kelvin
 
Something like this ?
For nbDec = 1 To 5
Debug.Print Format(123.45678, "0." & String$(nbDec, "0"))
Next nbDec

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi PHV

I have actually found that :

worksheetfunction.fixed(Number,Decimal places) will do the job

Thanks for your reply

Kelvin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top