VBA Formatpercent() : macro pour formater sous forme de pourcentage

La fonction FormatPercent dans VBA permet de réaliser une macro pour pour formater sous forme de pourcentage.

La fonction FormatPercent

La fonction VBA FormatPercent suit la syntaxe suivante :

Formatpercent(variable)

Exemple de macro avec FormatPercent

La macro

Sub nommacro()

Dim i As Integer

For i = 1 To 5

'Résultat dans Ligne de 1 à 5, Colonne 2
Cells(i, 2).Value = FormatPercent(Cells(i, 1))

Next i

End Sub

Les données sources

ABCDE
1112
237,3333333333333
312,4444444444444
44,14814814814815
51,38271604938272

Le résultat

ABCDE
111211 200,00%
237,33333333333333 733,33%
312,44444444444441 244,44%
44,14814814814815414,81%
51,38271604938272138,27%