1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| Sub conversion_to_pound()
Dim sheet As Worksheet
Dim cell
Dim C As Range
Dim new_value As Currency
Dim exchange_rate As Currency
Dim currency_ini As String
Dim currency_new As String
'Set search variable
currency_ini = ""
currency_new = "£"
exchange_rate = 0.83
'Parcourir l'ensemble des feuilles du classeur
For Each sheet In ThisWorkbook.Worksheets
'Parcourir l'ensemble des cellules de la feuille
For Each cell In sheet.Cells
' Si la cellule contient un nombre et le symbole
If IsNumeric(ActiveCell) And ActiveCell.Value Like money Then
' Convertir en £
new_value = ActiveCell.Value * exchange_rate
ActiveCell.Value = ActiveCell.Value * exchange_rate
'Modifier le format de la cellule pour remplacer par £
currency_ini = ActiveCell.NumberFormat
currency_new = Replace(currency_ini, money_ini, money_new)
ActiveCell.NumberFormat = currency_new
End If
Next
Next
End Sub |
Partager