Sub test()
Dim chaine$, adding$
chaine = "12345678910111213182"
adding = String(Len(chaine) Mod 3 + IIf(Len(chaine) Mod 3 > 0, 1, 0), "0")
chaine = Format(adding & chaine, Application.Rept(" @@@ ", Len(chaine)))
MsgBox chaine
End Sub
chaine = "12345678910111213182"
chaine = IIf(Len(chaine) Mod 3 > 0, "0", "") & Format(chaine, "0,000")
Sub test()
Dim chaine$, adding$
chaine = "1234567891011121318221"
chaine = IIf(Len(chaine) Mod 3 > 0, "0", "") & Format(chaine, "0,000")
MsgBox chaine
End Sub
chaine = "12345678910111213182"
txt = Format(chaine, "0,000")
txt = InStr(1, txt, Chr(160))
chaine = Application.Rept("0", 4 - txt) & Format(chaine, "0,000")
Sub test1()
Dim chaine
chaine = ("551561571581591501570268354298")
Debug.Print RTrim(Format(chaine, Application.Rept("000 ", Application.RoundUp(Len(CStr(chaine)) / 3, 0))))
End Sub
Function F(n As String) As String
Dim ub%, a$(), i%
ub = Application.RoundUp(Len(n) / 3, 0)
ReDim a(1 To ub)
For i = Len(n) - 2 To 1 Step -3
a(ub) = Mid(n, i, 3)
ub = ub - 1
Next
If a(1) = "" Then a(1) = Left(String(Abs(i) + 1, "0") & n, 3)
F = Join(a)
End Function
Function Groupe3(ByVal Txt As String) As String
Groupe3 = Format(CDec(Txt), "0,000")
End Function
Sub test()
chaine = "1234567831"
If Len(chaine) Mod 3 <> 0 Then chaine = Application.Rept("0", 3 - Len(chaine) Mod 3) & chaine 'on formate l'entier a 3 chiffre par tranche
MsgBox Format(chaine, Application.Rept(" 000", Len(chaine) / 3))
End Sub
Sub test()
chaine = "1234567831123654785654784521425654122145232564"
If Len(chaine) Mod 3 <> 0 Then chaine = Application.Rept("0", 3 - Len(chaine) Mod 3) & chaine 'on formate l'entier a 3 chiffre par tranche
MsgBox Format(chaine, Application.Rept(" @@@", Len(chaine) / 3))
End Sub
Function Groupe3(ByVal Txt As String) As String
Groupe3 = String((30 - Len(Txt)) Mod 3, "0") & Format(CDec(Txt), "0,000")
End Function
Function Groupe3(ByVal Txt As String) As String
Txt = String((300 - Len(Txt)) Mod 3, "0") & Txt
Groupe3 = Format(Txt, WorksheetFunction.Rept(" @@@", Len(Txt) / 3))
End Function