J'ai trouvé une solution à mon problème qui, je dois le reconnaître n'est pas bien élégante...
Je vuolais initialement convertir les nombres en chiffres romains d'une chaîne en chiffres arabes, et ma question visait à m'éviter la lourdeur des "if" successifs pour t et t-1...
Je ne doute pas qu'il y ai plus simple, mais le plaisir de réussir tout seul...
Merci quand même
Sub Romains()
Dim VF As Integer
For k = 3 To 24
Dim Tableau()
Compteur = 1
For I = 0 To Len(Cells(k, 1)) - 1
clef = Mid(Cells(k, 1), I + 1, 1)
ReDim Preserve Tableau(1 To Compteur)
Tableau(Compteur) = clef
Compteur = Compteur + 1
Next
t = 2
If Len(Cells(k, 1)) > 1 Then
While t <= Len(Cells(k, 1))
If Tableau(t) = "I" Then Tableau(t) = 1
If Tableau(t) = "V" Then Tableau(t) = 5
If Tableau(t) = "X" Then Tableau(t) = 10
If Tableau(t) = "L" Then Tableau(t) = 50
If Tableau(t) = "D" Then Tableau(t) = 100
If Tableau(t) = "M" Then Tableau(t) = 1000
If Tableau(t - 1) = "I" Then Tableau(t - 1) = 1
If Tableau(t - 1) = "V" Then Tableau(t - 1) = 5
If Tableau(t - 1) = "X" Then Tableau(t - 1) = 10
If Tableau(t - 1) = "L" Then Tableau(t - 1) = 50
If Tableau(t - 1) = "D" Then Tableau(t - 1) = 100
If Tableau(t - 1) = "M" Then Tableau(t - 1) = 1000
If Tableau(t - 1) >= Tableau(t) Then
If t < Len(Cells(k, 1)) Then
VF = VF + Tableau(t - 1)
Else: VF = VF + Tableau(t - 1) + Tableau(t)
End If
t = t + 1
Else: VF = VF + Tableau(t) - Tableau(t - 1)
t = t + 2
End If
Wend
ElseIf Len(Cells(k, 1)) = 1 Then
If Tableau(1) = "I" Then Tableau(1) = 1
If Tableau(1) = "V" Then Tableau(1) = 5
If Tableau(1) = "X" Then Tableau(1) = 10
If Tableau(1) = "L" Then Tableau(1) = 50
If Tableau(1) = "D" Then Tableau(1) = 100
If Tableau(1) = "M" Then Tableau(1) = 1000
VF = Tableau(1)
ElseIf Len(Cells(k, 1)) = 0 Then
VF = 0
End If
VF = 0
Next
End Sub