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 42 43 44
| Sub Donnees()
Dim derligA As Integer, derligF As Integer
Dim Plage As Range, PlageF As Range, c As Range
Dim derligD As Integer, Ldest As Integer, Cdest As Integer
Dim Product As String
Dim Prix As Variant
derligA = Range("A65536").End(xlUp).Row
Set Plage = Range(Cells(2, 1), Cells(derligA, 1))
derligF = Range("F65536").End(xlUp).Row
Set PlageF = Range(Cells(2, 6), Cells(derligF, 6))
Set Plage = Application.Union(Plage, PlageF)
For Each c In Plage
i = c.Row
j = c.Column
If c.Value <> "" And Cells(i, j + 2).Value <> "" Then 'ici j+2 à la place de j+3 (ou c.offset(0,2) sans passer par i et j)
Product = c.Value
Prix = Cells(i, j + 2).Value 'ici aussi j+2 à la place de j+3
With Worksheets("Données") 'à Partir d'ici, ajouter des . aux ranges
derligD = .Range("A65536").End(xlUp).Row
Set PlageD = .Range(.Cells(1, 1), .Cells(derligD, 1))
Set trouve = PlageD.Find(Product, PlageD.Cells(1), xlValues, xlWhole, xlByColumns, xlNext)
If Not trouve Is Nothing Then
Ldets = trouve.Row
Cdest = trouve.Column
.Cells(Ldets, Cdest + 1).Value = Prix
Else
.Cells(derligD + 1, 1).Value = Product
.Cells(derligD + 1, 2).Value = Prix
End If
End With
End If
Next c
End Sub |
Partager