|
试试看- Sub test()
- Dim i&, j&, k&, a&, x&, st$, tj, st1$, st2$
- Dim ar, br
- ar = Sheet2.Range("a2:f" & Sheet2.Range("a" & Rows.Count).End(xlUp).Row)
- tj = Sheet2.Range("h2:m15")
- ReDim br(1 To UBound(ar), 1 To 6)
- For i = 1 To UBound(ar)
- For k = 1 To UBound(tj)
- st = "": st1 = "": st2 = ""
- For a = 1 To 6
- st = st & tj(k, a)
- Next
- If Len(st) Then
- For a = 2 To 6
- st1 = st1 & "|" & tj(k, a)
- If tj(k, a) <> "" Then
- st2 = st2 & "|" & ar(i, a)
- Else
- st2 = st2 & "|"
- End If
- Next
- If tj(k, 1) = "" Or ar(i, 1) Like tj(k, 1) Then
- If st1 = st2 Then
- x = x + 1
- For a = 1 To 6
- br(x, a) = ar(i, a)
- Next
- End If
- End If
- End If
- Next
- Next
- Sheet2.Range("o2:t" & Rows.Count).ClearContents
- Sheet2.Range("o2").Resize(x, 6) = br
- End Sub
复制代码 |
|