Catégories
Macros VBA

VBA Format() : macro pour formater en fonction des instructions de mise en forme

Partager :

La fonction Format dans VBA est utilisée pour formater en fonction des instructions de mise en forme.

La fonction Format

La fonction VBA Format suit la syntaxe suivante :

Format(variable)

Exemple de macro avec Format

La macro

Sub nommacro()

Dim c As Range 'Variable

For Each c In Range("A1:A5") 'Plage

'Cellule actuellement sélectionnée
ActiveCell.Offset(0, 0).FormulaR1C1 = _
Format(c)

'Cellule suivante située en bas
ActiveCell.Offset(1, 0).Select

Next c

End Sub

Les données sources

ABCD
1
2
3
4
5

Le résultat

ABCD
1
2
3
4
5