Sub 筛选()
Application.ScreenUpdating =False
Dim ar As Variant
Dim br(), cr(), dr()
With Sheets("总筛选前的表")
r =.Cells(Rows.Count,1).End(xlUp).Row
If r <5 Then MsgBox "总表为空!": End
ar =.Range("a5:y"& r)
End With
ReDim cr(1 To UBound(ar),1 To 4)
ReDim dr(1 To UBound(ar),1 To 4)
With Sheets("客户表")
ws =.UsedRange.Rows.Count +2.Cells(ws,1)= Format(Date,"yyyymmdd")
y =2
For j =9 To UBound(ar,2) Step 8
n =0
ReDim br(1 To UBound(ar),1 To 4)
For i =1 To UBound(ar)
If Trim(ar(i, j))="关键字" Then
n = n +1
m =0
For s = j -7 To j -4
m = m +1
br(n, m)= ar(i, s)
Next s
End If
Next i
If n >0 Then .Cells(ws, y).Resize(n, UBound(br,2))= br
y = y +5
Next j
End With
Application.ScreenUpdating =True
MsgBox "ok!"
End Sub