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
|
Sub match()
Dim C As Range
Dim D As Range
wkname = ActiveWorkbook.Name
shname = "a"
Worksheets(shname).Activate
Workbooks.Open Filename:=file2open
wkname2 = ActiveWorkbook.Name
shname2 = "b"
'a
NbreLigne1 = 500000
'Workbooks(wkname).Worksheets(shname).Cells1, 1).End(xlDown).Row
NbreLigne3 = 500000
'Workbooks(wkname).Worksheets(shname).Cells(1, 2).End(xlDown).Row
'b
NbreLigne2 = Workbooks(wkname2).Worksheets(shname2).Cells(1, 1).End(xlDown).Row
NbreLigne4 = Workbooks(wkname2).Worksheets(shname2).Cells(2, 1).End(xlDown).Row
With Workbooks(wkname).Worksheets(shname).Range("a2:z" & NbreLigne1)
For i = 1 To NbreLigne2
Set C = .Find(Workbooks(wkname2).Worksheets(shname2).Cells(i, 1), LookIn:=xlValues)
Set D = .Find(Workbooks(wkname2).Worksheets(shname2).Cells(i, 2), LookIn:=xlValues)
If Not C Is Nothing And Not D Is Nothing Then
' And C.Row = D.Row - ----- wkname2 = ActiveWorkbook.Name
' shname2 = "b"
Workbooks(wkname).Worksheets(shname).Cells(C.Row, 3).Value = Workbooks(wkname2).Worksheets(shname2).Cells(i, 3).Value
End If
End If
Next i
End With
'End With
End Sub |
Partager