Try something like
Dim NumDecPlaces As Long
Dim NumFormat As String
NumDecPlaces = Range("B1").Value
NumFormat = "0." & String$(NumDecPlaces, "0") & ";-0." & "0." & _
String$(NumDecPlaces, "0") & ";@"
Range("A1").NumberFormat = NumFormat
This will format A1 with the number of decimal places specified in cell B1.
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
wrote in message
oups.com...
set the numberformat property.
in VBA (as an example) it would be
Range("A20").Numberformat = "#,###.000"
for 3 decimals.
Thanks Tom but the number of decimal is not all the time 3 but depends
of a value placed in a specific cell, the number of decimal is the
same for all the column above. Then the number of decimal is column
depending.
Regards,