Thread: Custom Zeros
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips[_4_] Bob Phillips[_4_] is offline
external usenet poster
 
Posts: 834
Default Custom Zeros

Try

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "B1" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target

If IsNumeric(.Value2) Then

Me.Columns(1).NumberFormat = "#,##0." & Left$("0000000000",
Len(.Value2) - InStr(.Value2, "."))
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--

HTH

Bob

"Totoshi" wrote in message
...
Hi,


i have a issue in excel 2003 VBA, how can i costumize the decimal
places for a range of cells with the number format from other cell.
For example :

in Column A i have 1.21 ; 1.56 ; 1.789 ; 1.9899 ; 0.1

and in cell B1 i have the number 0.001 .

So i want to format by a function Column A so the contents in cell
appears like this :

1.210 ; 1.560 ; 1.789 ; 1.990 ; 0,100 .

Can anyone help me with this ?

Thank you , Cheers