1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Sub Test()
Dim wkb As Workbook: Set wkb = ThisWorkbook
Dim ligne As Single
With wkb
Dim sht1 As Worksheet: Set sht1 = Worksheets("Feuil1")
Dim sht2 As Worksheet: Set sht2 = Worksheets("Feuil2")
End With
With sht1 ' Feuille 1
For ligne = 2 To Cells(Rows.Count, 1).End(xlUp).Row
' Si cellule Feuil1 < Feuil2
If .Cells(ligne, 3) < sht2.Cells(ligne, 3) Then
' cel Feuil2 prend la valeur Cel Feuil1
sht2.Cells(ligne, 3) = .Cells(ligne, 3)
Else ' Sinon
' Police Cel Feuil2 rouge
sht2.Cells(ligne, 3).Font.ColorIndex = 3
End If
Next
End With
End Sub |
Partager