Sub Ctrl_Prix() 'Contrôle Format Prix
Dim R As Range
Dim DecSep$
Dim x#
Dim SystemSeparator$
Dim tampon$
Dim LenTampon&
Dim var
Dim i&
Dim A$
With Application
If Application.UseSystemSeparators Then
tampon$ = Space(255)
LenTampon& = GetLocaleInfo(GetSystemDefaultLCID, &HE, tampon$, 255)
DecSep$ = Left$(tampon$, LenTampon& - 1)
Else
DecSep$ = Application.International(xlDecimalSeparator)
End If
End With
Sheets(CONTROLE).Range("B14:IV14").Clear
Set R = Sheets(DATA).Range("AH2", Sheets(DATA).[AH65536].End(xlUp))
var = R
For i& = 1 To UBound(var, 1)
A$ = CStr(var(i&, 1))
If DecSep$ = "." Then
A$ = Replace(A$, ",", DecSep$)
ElseIf DecSep$ = "," Then
A$ = Replace(A$, ".", DecSep$)
End If
A$=Replace(A$," ","") 'ajout pmo
If IsNumeric(A$) Then
'--- Détection des nombres avec plus de 2 décimales ---
If Len(Mid(A$, InStr(1, A$, DecSep$) + 1)) > 2 Then
x# = CDbl(A$)
x# = CDbl(CLng(x# * 100) / 100)
A$ = CStr(x#)
End If
Else
Sheets(CONTROLE).Range("IV14").End(xlToLeft).Offset(0, 1).Value = "AH" & i& + 1 & ""
End If
var(i&, 1) = A$
Next i&
R = var
R.NumberFormat = "#,##0.00" 'modification pmo
R.HorizontalAlignment = xlRight
Call CleanImages
End Sub