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 45
| Sub kind()
Range("b2:d10000").Clear
g = 2
With sheet3
On Error Resume Next
Dim collon_d As Collection, dd As Range
Dim collon_b As Collection, bb As Range
Dim collon_c As Collection, cc As Range
''''''''''''''''''''''''''''''''''''''''''
Set collon_d = New Collection
Set collon_b = New Collection
Set collon_c = New Collection
'''''''''''''''''''''''''''''''''''''''''''''''''
LsRow2 = .Range("d" & Rows.Count).End(xlUp).Row
For Each dd In .Range("d4:d" & LsRow2)
collon_d.Add dd.Value, dd.Text
Next dd
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
LsRow = .Range("b" & Rows.Count).End(xlUp).Row
For Each bb In .Range("b4:b" & LsRow)
collon_b.Add bb.Value, bb.Text
Next bb
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
LsRow = .Range("c" & Rows.Count).End(xlUp).Row
For Each cc In .Range("c4:c" & LsRow)
collon_c.Add cc.Value, cc.Text
Next cc
'''''''''''''''''''''''''''''''''''''''''''''''''''
For i = 1 To collon_d.Count
sheet4.Range("b" & Rows.Count).End(xlUp).Offset(1, 0).Value = collon_d(i)
'---------------------------------------------------------------
For g = 1 To collon_c.Count
If CStr(sheet3.Cells(g + 4, 4).Text) = CStr(collon_d(i)) Then
sheet4.Range("d" & Rows.Count).End(xlUp).Offset(collon_d.Count, 0).Value = CStr(collon_c(g))
End If
'----------------------------------
For f = 1 To collon_b.Count
If CStr(sheet3.Cells(f + 4, 3).Text) = CStr(collon_c(g)) Then
sheet4.Range("c" & Rows.Count).End(xlUp).Offset(collon_c.Count, 0).Value = CStr(collon_b(f))
End If
Next
Next
Next
End With
End Sub |
Partager