I have this code :
Option Explicit
Public Function Entete(Compte$, Montants As Range, _
Optional mois$, Optional année$) As String
On Error GoTo ErrMA
Dim DS As Date, M As Byte, A%, c$, cler$, chn$, d&
c = "00799999" & Format(Right(Compte, 12), String$(12, "0"))
cler = CStr(Format(WorksheetFunction.Sum(Montants) * 100, String$(13, "0")))
DS = Now(): If mois = "" Then M = Month(DS) Else M = Val(mois)
If année = "" Then A = Year(DS) Else A = Val(année)
d = Cells(Rows.Count, "G").End(xlUp).Row - 1
chn = Format(d, String$(7, "0")) & Format(M, "00") & Format(A, "0000")
Entete = "*" & c & cler & chn & Space$(14) & "0"
Exit Function
ErrMA: Entete = "Vérifiez ces 2 paramètres : mois, année."
End Function
I want to modify this line :
c = "00799999" & Format(Compte, String$(12, "0"))
« compte » always begins with 00799999 and is ‘20’ numbers long.
So when I type 103, I get 00799999000000000103
So when I type 1103, I get 00799999000000001103
So when I type 11103, I get 00799999000000011103
So when I type 999000030003458, I get 00799999000030003458
All Works fine, until I type 9999000030003458 or 99999000030003458 or 799999000030003458 or 0799999000030003458 or 00799999000030003458, I don’t get the desired result.
For example when I type 799999000030003458 I want the result to be : 00799999000030003458
And when I type 07999990000030003458 I want the result to be : 00799999000030003458.
Any help ?
https://www.cjoint.com/c/MHvkLsthQC5rhodo Je t'attends (merci d'avance)