|
- Sub test()
- Dim sH As Worksheet, sH1 As Worksheet, i&, j&, Arr, mRow&, SFstr$, zTstr$, jL&
- Set sH1 = Worksheets("查询")
- With sH1
- mRow = .UsedRange.Rows.Count
- If mRow > 5 Then .Rows("6:" & mRow).Delete
- SFstr = .[c2]
- zTstr = .[c3]
- If SFstr = "" Or zTstr = "" Then Exit Sub
- End With
- For Each sH In Worksheets
- With sH
- If .Name <> sH1.Name Then
- Arr = .[a1].CurrentRegion
- jL = 0
- ReDim brr(1 To UBound(Arr, 1) + 1, 1 To UBound(Arr, 2))
- For i = 1 To UBound(Arr, 1)
- If Arr(i, 1) = zTstr And Arr(i, 2) = SFstr Then
- jL = jL + 1
- For j = 1 To UBound(Arr, 2)
- brr(jL, j) = Arr(i, j)
- Next j
- End If
- Next i
- If jL Then
- With sH1
- mRow = .Cells(.Rows.Count, "A").End(3).Row
- If mRow <= 5 Then mRow = 6 Else mRow = mRow + 1
- .Cells(mRow, 1).Resize(1, UBound(Arr, 2)) = Arr
- .Cells(mRow, 1).Resize(1, UBound(Arr, 2)).Interior.Color = 12874308
- .Cells(mRow + 1, 1).Resize(jL, UBound(brr, 2)) = brr
- End With
- End If
- End If
- End With
- Next
- sH1.UsedRange.EntireColumn.AutoFit
- MsgBox "Done!"
- End Sub
复制代码 |
|