ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   format variable to 3 decimal (https://www.excelbanter.com/excel-programming/304418-format-variable-3-decimal.html)

Wandering Mage

format variable to 3 decimal
 
What I am trying to do, is use a variable to as part of
the name in a Chart that is created using a macro. When I
go Round(takttime, 3), takttime is the variable, and it
will round out to 3 decimals as it is supposed to, but I
also want it to SHOW THE ZEROS UP TO # DECIMALS. So, for
instance, a 5 should show up as 5.000. The problem is, I
am not just writing to a cell, so its not like I can just
format the cell to 3 decimals and be done with it. Does
anyone know how I get this to output to include 0's when
rounding? Help is, very much, as always, appreciated!
Thanks:)

K Dales

format variable to 3 decimal
 
Use the Format function:

=Format(Round(taktime,3),"#.000")

This converts to Text and specifies the format so it can
be assigned to any String variable or to things like the
names in your chart, etc. For more info look up the
Format function and "User-Defined Numeric Formats" in VBA
help.

-----Original Message-----
What I am trying to do, is use a variable to as part of
the name in a Chart that is created using a macro. When

I
go Round(takttime, 3), takttime is the variable, and it
will round out to 3 decimals as it is supposed to, but I
also want it to SHOW THE ZEROS UP TO # DECIMALS. So, for
instance, a 5 should show up as 5.000. The problem is, I
am not just writing to a cell, so its not like I can just
format the cell to 3 decimals and be done with it. Does
anyone know how I get this to output to include 0's when
rounding? Help is, very much, as always, appreciated!
Thanks:)
.



All times are GMT +1. The time now is 10:34 AM.

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