我为自动化目的编写了以下vba编码。但是你能建议我去掉哪些步骤可以跑得更快吗?
Sub listof()
LQCC = Sheets(1).Cells(Rows.Count, 6).End(xlUp).Row - 1
ytqcl = Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row - 1
tr = Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row - 1
tqcp = Sheets(1).Cells(Rows.Count, 6).End(xlUp).Row - 1
ssel = Int(tr / tqcp)
Dim ListofQCUsers() As Variant
ReDim ListofQCUsers(LQCC) As Variant
For y = 1 To UBound(ListofQCUsers)
ListofQCUsers(y) = Range("f" & y + 1).Value
Next y
sampleselection = 0
If ListofQCUsers(UBound(ListofQCUsers)) = Range("a2").Value Then
Range("f2").Value = ListofQCUsers(UBound(ListofQCUsers))
Range("f" & LQCC + 1).Value = ListofQCUsers(1)
For y = 1 To UBound(ListofQCUsers)
ListofQCUsers(y) = Range("f" & y + 1).Value
Next y
End If
Range("f2", "f" & LQCC + 1).Delete
For Z = ytqcl To 1 Step -1
For x = 1 To UBound(ListofQCUsers)
For d = 1 To ssel And Z <> 0
If Z > 0 Then
If ListofQCUsers(x) <> Range("a" & Z).Offset(1, 0).Value Then
LSN = Sheets(3).Cells(Rows.Count, 1).End(xlUp).Row + 1
Range("a" & Z).Offset(1, 0).Resize(1, 3).Copy
Sheets(3).Range("a" & LSN).PasteSpecial xlPasteAll
Sheets(3).Range("a" & LSN).Value = ListofQCUsers(x)
Range("a" & Z).Offset(1, 0).Resize(1, 3).Delete
sampleselection = sampleselection + 1
End If
Z = Z - 1
End If
Next d
sampleselection = 1
Z = Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row - 1
If x = 1 Then
Exit Sub
End If
Next x
ytqcl = Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row - 1
Next Z
ytqcl = Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row
Range("a2", "a" & ytqcl).Resize(1, 3).EntireRow.Delete
End Sub
我想将已处理的qc索赔分配给不同的人,即流程人员不应该将相同的索赔分配给qc。
以上代码给出100%准确的数据,但我想知道哪些步骤是不需要一次又一次。
通过切换ScreenUpdating
和Calculation
,您将获得显著的速度提升。
Sub listof()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
'Your Code
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub