XL 2016 Conversion en devise

marie58

XLDnaute Nouveau
Bonjour,
J'ai un tableau de reporting que je remplis en monnaie étrangère. Je dois présenter ce tableau en EUR. J'aimerai pouvoir cliquer sur un bouton et qu'une macro s'exécute afin d'avoir ce même tableau en EUR. Ce tableau me sert de base pour des graphiques et des tableaux d'indicateurs. C'est pour cette raison que j'aimerai que ce soit le même document.
Malheureusement je n'ai pas suffisamment de connaissance en vba pour faire cette manipulation. J'espère que quelqu'un pourra m'aider.
Merci d'avance
 

Pièces jointes

  • REPORTING.xlsx
    38.9 KB · Affichages: 27

cp4

XLDnaute Barbatruc
Bonjour,

Si j'ai bien compris. Cellule M1 utilisée pour ne pas convertir plusieurs fois de suite.
à tester. Code à copier dans un module standard et enregistrer fichier au format xlsm ou xlsb
VB:
Option Explicit

Sub conversion()
Dim i As Integer, j As Integer, moné As Double
With ActiveSheet
If .Range("M1").Value = "Converti" Then
MsgBox "Monnaie déjà convertie!" & vbLf & "Fin de l'opération.", vbInformation + vbOKOnly, "CONVERTION"
Exit Sub
Else
.Range("M1") = "Converti"
moné = .Range("J2").Value
For j = 4 To 15

For i = 8 To 17
If IsEmpty(.Cells(i, j).Value) Then
.Cells(i, j).Value = ""
Else
.Cells(i, j).Value = .Cells(i, j).Value * moné
End If
Next i

For i = 22 To 32
If IsEmpty(.Cells(i, j).Value) Then
.Cells(i, j).Value = ""
Else
.Cells(i, j).Value = .Cells(i, j).Value * moné
End If
Next i

For i = 39 To 57
If IsEmpty(.Cells(i, j).Value) Then
.Cells(i, j).Value = ""
Else
.Cells(i, j).Value = .Cells(i, j).Value * moné
End If
Next i

For i = 59 To 60
If IsEmpty(.Cells(i, j).Value) Then
.Cells(i, j).Value = ""
Else
.Cells(i, j).Value = .Cells(i, j).Value * moné
End If
Next i

For i = 62 To 68
If IsEmpty(.Cells(i, j).Value) Then
.Cells(i, j).Value = ""
Else
.Cells(i, j).Value = .Cells(i, j).Value * moné
End If
Next i

For i = 70 To 81
If IsEmpty(.Cells(i, j).Value) Then
.Cells(i, j).Value = ""
Else
.Cells(i, j).Value = .Cells(i, j).Value * moné
End If
Next i

For i = 85 To 87
If IsEmpty(.Cells(i, j).Value) Then
.Cells(i, j).Value = ""
Else
.Cells(i, j).Value = .Cells(i, j).Value * moné
End If
Next i

For i = 92 To 97
If IsEmpty(.Cells(i, j).Value) Then
.Cells(i, j).Value = ""
Else
.Cells(i, j).Value = .Cells(i, j).Value * moné
End If
Next i

For i = 101 To 105
If IsEmpty(.Cells(i, j).Value) Then
.Cells(i, j).Value = ""
Else
.Cells(i, j).Value = .Cells(i, j).Value * moné
End If
Next i

For i = 109 To 112
If IsEmpty(.Cells(i, j).Value) Then
.Cells(i, j).Value = ""
Else
.Cells(i, j).Value = .Cells(i, j).Value * moné
End If
Next i

 i = 116
If IsEmpty(.Cells(i, j).Value) Then
.Cells(i, j).Value = ""
Else
.Cells(i, j).Value = .Cells(i, j).Value * moné
End If

Next j
MsgBox "Convertion terminée!", vbInformation + vbOKOnly, "CONVERTION DEVISE"
End If
End With
End Sub
Bonne journée.
 

marie58

XLDnaute Nouveau
Bonjour,

Si j'ai bien compris. Cellule M1 utilisée pour ne pas convertir plusieurs fois de suite.
à tester. Code à copier dans un module standard et enregistrer fichier au format xlsm ou xlsb
VB:
Option Explicit

Sub conversion()
Dim i As Integer, j As Integer, moné As Double
With ActiveSheet
If .Range("M1").Value = "Converti" Then
MsgBox "Monnaie déjà convertie!" & vbLf & "Fin de l'opération.", vbInformation + vbOKOnly, "CONVERTION"
Exit Sub
Else
.Range("M1") = "Converti"
moné = .Range("J2").Value
For j = 4 To 15

For i = 8 To 17
If IsEmpty(.Cells(i, j).Value) Then
.Cells(i, j).Value = ""
Else
.Cells(i, j).Value = .Cells(i, j).Value * moné
End If
Next i

For i = 22 To 32
If IsEmpty(.Cells(i, j).Value) Then
.Cells(i, j).Value = ""
Else
.Cells(i, j).Value = .Cells(i, j).Value * moné
End If
Next i

For i = 39 To 57
If IsEmpty(.Cells(i, j).Value) Then
.Cells(i, j).Value = ""
Else
.Cells(i, j).Value = .Cells(i, j).Value * moné
End If
Next i

For i = 59 To 60
If IsEmpty(.Cells(i, j).Value) Then
.Cells(i, j).Value = ""
Else
.Cells(i, j).Value = .Cells(i, j).Value * moné
End If
Next i

For i = 62 To 68
If IsEmpty(.Cells(i, j).Value) Then
.Cells(i, j).Value = ""
Else
.Cells(i, j).Value = .Cells(i, j).Value * moné
End If
Next i

For i = 70 To 81
If IsEmpty(.Cells(i, j).Value) Then
.Cells(i, j).Value = ""
Else
.Cells(i, j).Value = .Cells(i, j).Value * moné
End If
Next i

For i = 85 To 87
If IsEmpty(.Cells(i, j).Value) Then
.Cells(i, j).Value = ""
Else
.Cells(i, j).Value = .Cells(i, j).Value * moné
End If
Next i

For i = 92 To 97
If IsEmpty(.Cells(i, j).Value) Then
.Cells(i, j).Value = ""
Else
.Cells(i, j).Value = .Cells(i, j).Value * moné
End If
Next i

For i = 101 To 105
If IsEmpty(.Cells(i, j).Value) Then
.Cells(i, j).Value = ""
Else
.Cells(i, j).Value = .Cells(i, j).Value * moné
End If
Next i

For i = 109 To 112
If IsEmpty(.Cells(i, j).Value) Then
.Cells(i, j).Value = ""
Else
.Cells(i, j).Value = .Cells(i, j).Value * moné
End If
Next i

 i = 116
If IsEmpty(.Cells(i, j).Value) Then
.Cells(i, j).Value = ""
Else
.Cells(i, j).Value = .Cells(i, j).Value * moné
End If

Next j
MsgBox "Convertion terminée!", vbInformation + vbOKOnly, "CONVERTION DEVISE"
End If
End With
End Sub
Bonne journée.
Bonjour,
Merci pour ce code.
Cela fonctionne bien. Toutefois je trouve le traitement assez long. De plus j'aimerai pouvoir le reconvertir en RON. Car ce document est complété dans la monnaie locale.
En fait l'idéal serait de pouvoir cliquer sur un bouton EUR et d'avoir le tableau en EUR, puis de recliquer sur le bouton afin de retrouver les données telles qu'elles étaient remplies en RON.
C'est peut être compliqué à réaliser ?
Merci
 

cp4

XLDnaute Barbatruc
Bonjour,

Toutefois je trouve le traitement assez long. De plus j'aimerai pouvoir le reconvertir en RON. Car ce document est complété dans la monnaie locale.
Pour le temps d’exécution: il est proportionnel au nombre de cellules à traiter.
Tu n'avais pas mentionné le taux de change, j'ai donc pris une valeur au pif.
Ce n'est pas difficile de passer d'une monnaie à l'autre. Si on a multiplié les valeurs pour passer à une autre monnaie, il suffit de diviser pour revenir aux valeurs initiales.
 

sylvanu

XLDnaute Barbatruc
Supporter XLD
Bonjour tout le fil,
Un essai simple en PJ avec :
VB:
Sub Convertir()
    Dim L%, C%
    On Error GoTo Fin:
    If [B1] = "Value in RON" Then
        [B1] = "Value in EURO": Taux = 1 / [J2]
    Else
        [B1] = "Value in RON": Taux = [J2]
    End If
    Application.ScreenUpdating = False
    For C = 4 To 16
        For L = 6 To Range("A65500").End(xlUp).Row
            On Error Resume Next
            If Cells(L, C) <> "" Then
                If Left(Cells(L, "B"), 1) <> "%" Then
                    Cells(L, C) = Cells(L, C) * Taux
                End If
            End If
        Next L
    Next C
Fin:
End Sub
Le changement de monnaie se fait par appui sur B1.
J'ai pris par défaut 5 Lei par €. A modifier.
 

Pièces jointes

  • REPORTING.xlsm
    45.5 KB · Affichages: 7

Discussions similaires

Réponses
5
Affichages
319
Réponses
16
Affichages
541

Statistiques des forums

Discussions
312 466
Messages
2 088 663
Membres
103 910
dernier inscrit
amor57