下面的代码
- 将所有九张纸(如果名称存在)中的第 8 行复制到一张名为“安装”的纸上
- 任何低于 60% 的记录都会被自动过滤并从主工作表中删除(比在复制前自动过滤九个工作表中的每一个更有效)
- 在顶部添加空白行以在第 8 行开始“安装”
*如果您确实需要从第 1 行到第 7 行的标题行,那么可以从其中一张推销员表中复制这些行 - 让我知道 *
Sub QuickCombine()
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim rng1 As Range
Dim strShts()
Dim strWs As Variant
Dim lngCalc As Long
With Application
.ScreenUpdating = False
lngCalc = .Calculation
.Calculation = xlCalculationManual
End With
Set ws1 = Sheets("Install")
ws1.UsedRange.Cells.Clear
strShts = Array("Jeff", "John", "Tim", "Pete", "Chad", "Bob", "Kevin", "Mike", "Bill")
For Each strWs In strShts
On Error Resume Next
Set ws2 = Sheets(strWs)
On Error GoTo 0
If Not ws2 Is Nothing Then
Set rng1 = ws2.Range(ws2.[v8], ws2.Cells(Rows.Count, "v").End(xlUp))
rng1.EntireRow.Copy ws1.Cells(ws1.Cells(Rows.Count, "v").End(xlUp).Offset(1, 0).Row, "A")
End If
Set ws2 = Nothing
Next
With ws1
.[v1] = "dummy"
.Columns("V").AutoFilter Field:=1, Criteria1:="<60%"
.Rows.Delete
.Rows("1:7").Insert
End With
With Application
.ScreenUpdating = True
.Calculation = lngCalc
End With
End Sub