Private Sub Worksheet_Activate()
Dim c As Range, pl As Range, nbDec, i As Long
With Worksheets("A COMPLETER")
Set c = .Columns(2).Find("Nb de décimales", , xlValues, xlWhole)
If c Is Nothing Then
MsgBox "Ligne 'Nb de décimales' non trouvée": Exit Sub
Else
' tableau nb décimales
nbDec = Intersect(.Range(Split(Split([A6].Formula, "!")(1), ")")(0)).EntireColumn, c.EntireRow).Value
End If
End With
Set c = Columns(1).Find("PARAMETRES", , xlValues, xlWhole)
If c Is Nothing Then
MsgBox "PARAMETRES non trouvé"
Else
Set pl = c.CurrentRegion
For Each c In c.Offset(1).CurrentArray ' matrice noms tests
i = i + 1
If IsNumeric(nbDec(1, i)) Then
Intersect(c.EntireRow, pl.Columns).NumberFormat = IIf(nbDec(1, i) = 0, "0", "0." & Application.Rept("0", nbDec(1, i)))
End If
Next c
End If
End Sub