teodormircea
XLDnaute Occasionnel
Bonjour le forum
J'ai fait une macros qui doit comparer les valeurs entre 2 colonnes , si egalite trouve entre 2 cellules mettre ok dans une autre si non KO.
J'essaye de remplacer la fonction =IF(VAL1=VAL2,"OK","KO")
Merci d'avance
J'ai fait une macros qui doit comparer les valeurs entre 2 colonnes , si egalite trouve entre 2 cellules mettre ok dans une autre si non KO.
J'essaye de remplacer la fonction =IF(VAL1=VAL2,"OK","KO")
Code:
Sub format()
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
Dim x As Integer
Dim Y As Integer
Dim Z As Integer
Dim r As Range
Dim s As Range
Dim t As Range
x = CLng(InputBox(Prompt:="Quelle colonne?"))
If (x < 1) + (x > Columns.Count) Then Exit Sub
LastRow = ActiveSheet.Cells(Rows.Count, x).End(xlUp).Row
Y = CLng(InputBox(Prompt:="Quelle colonne?"))
If (Y < 1) + (Y > Columns.Count) Then Exit Sub
LastRow = ActiveSheet.Cells(Rows.Count, Y).End(xlUp).Row
Z = CLng(InputBox(Prompt:="Quelle colonne?"))
If (Y < 1) + (Y > Columns.Count) Then Exit Sub
LastRow = ActiveSheet.Cells(Rows.Count, Y).End(xlUp).Row
For Each r In Range(Cells(1, x), Cells(Rows.Count, x).End(xlUp))
Next
For Each s In Range(Cells(1, Y), Cells(Rows.Count, Y).End(xlUp))
Next
For Each t In Range(Cells(1, Z), Cells(Rows.Count, Z).End(xlUp))
Next
If r.Value = s.Value Then
t.Value = "OK"
Else
t.Value = "KO"
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End If