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).SelectNext c
End Sub
Les données sources
A | B | C | D | |
---|---|---|---|---|
1 | ||||
2 | ||||
3 | ||||
4 | ||||
5 |
Le résultat
A | B | C | D | |
---|---|---|---|---|
1 | ||||
2 | ||||
3 | ||||
4 | ||||
5 |