|
楼主 |
发表于 2016-2-19 17:47
|
显示全部楼层
谢谢版主大大,已经弄好了。这几天谢谢你那么细心耐心的帮我解答,版主大好人啊
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(0, 0) <> "B6" And Target.Address(0, 0) <> "B7" Then Exit Sub
If [b6] = "" And [b7] = "" Then Exit Sub
Dim arr, brr(1 To 100000, 1 To 2), i&, m&, t1$, t2$, sh As Worksheet
t1 = [b6]
t2 = [b7]
With CreateObject("VBSCRIPT.REGEXP")
.Global = True
.Pattern = "(.|$)"
For Each sh In Worksheets
If sh.Name <> "首页" Then
arr = sh.Range("B5:C" & sh.Range("B" & Rows.Count).End(xlUp).Row)
For i = 1 To UBound(arr)
If arr(i, 1) Like .Replace(t1, "*$1") And InStr(arr(i, 2), t2) > 0 Then
m = m + 1
brr(m, 1) = arr(i, 1)
brr(m, 2) = arr(i, 2)
End If
Next
End If
Next
End With
Range("A8:B" & Rows.Count).ClearContents
If m > 0 Then Range("A9").Resize(m, 2) = brr
End Sub
|
|