Function Reformu(ByVal Z As String) As String
Dim TS1() As String, P As Long, TS2() As String, TS3() As String, Fin As String, M As Long
TS1 = Split(Replace(Z, " ", ""), ",")
For P = 0 To UBound(TS1)
TS2 = Split(TS1(P), "(")
If UBound(TS2) > 0 Then
TS3 = Split(TS2(1), ")")
M = TêteÉliminée(TS3(1))
TS1(P) = RFMult(TS2(0), 1) & RFMult(TS3(0), M) & RFMult(TS3(1), 1)
Else
TS1(P) = RFMult(TS1(P), 1)
End If: Next P
Reformu = Join(TS1, "")
End Function
Function RFMult(ByVal Z As String, ByVal M As Long) As String
Dim P As Long, C As String * 1, N As Long
M = M * TêteÉliminée(Z)
If Z = "" Then Exit Function
For P = 1 To Len(Z)
C = Mid$(Z, P, 1)
If C Like "#" Then
N = 10 * N + C
ElseIf UCase(C) <> LCase(C) Then
If C = UCase(C) And RFMult <> "" Then
If N = 0 Then N = 1
RFMult = RFMult & N * M
N = 0: End If
RFMult = RFMult & C: End If
Next P
If N = 0 Then N = 1
RFMult = RFMult & N * M
End Function
Function TêteÉliminée(ByRef Z As String) As Long
While Left$(Z, 1) Like "#": TêteÉliminée = 10 * TêteÉliminée + Left$(Z, 1): Z = Mid$(Z, 2): Wend
If TêteÉliminée = 0 Then TêteÉliminée = 1
End Function