Custom Zeros
Hi,
Try this
Private Sub Worksheet_Change(ByVal Target As Range)
Dim MyRange As Range
Dim LastRow As Long
If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub
If Target.Address = "$B$1" Then
Application.EnableEvents = False
LastRow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set MyRange = Range("A1:A" & LastRow)
r = Len(Range("B1") - Int(Range("B1"))) - 2
MyRange.NumberFormat = "0." & WorksheetFunction.Rept("0", r)
End If
Application.EnableEvents = True
End Sub
--
Mike
When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
"Totoshi" wrote:
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
.
|