看了楼主的第5讲,想套用,但不会,不知如何才能让下面这个宏运行得更快? Sub LBLaw()
On Error Resume Next
Application.ScreenUpdating = False
Range("A3:F203,G4:G203").ClearContents
If Cells(1, 12) = "" Or Cells(1, 19) = "" Or Cells(1, 26) = "" Then
Exit Sub
Else
For i = 1 To 6
If i < Cells(1, 19) Then: cb = i + 2: Else cb = i + 3
For j = 1 To Cells(1, 26)
If Cells(1, 12) = 1 Then
Cells(j + 2, i).FormulaR1C1 = Application.WorksheetFunction.Index(Sheets(1).Columns(cb), Application.WorksheetFunction.Count(Sheets(1).Columns(9)) - (Cells(1, 26) - 2 - j))
Else
If Cells(1, 19) = 7 Then
Cells(j + 2, i).FormulaR1C1 = Application.WorksheetFunction.Large(Sheets(1).Range("C" & Application.WorksheetFunction.Count(Sheets(1).Columns(9)) - (Cells(1, 26) - 2 - j) & ":H" & Application.WorksheetFunction.Count(Sheets(1).Columns(9)) - (Cells(1, 26) - 2 - j)), 7 - i)
Else
If i < Cells(1, 19) Then
Cells(j + 2, i).FormulaR1C1 = Application.WorksheetFunction.Large(Sheets(1).Range("C" & Application.WorksheetFunction.Count(Sheets(1).Columns(9)) - (Cells(1, 26) - 2 - j) & ":H" & Application.WorksheetFunction.Count(Sheets(1).Columns(9)) - (Cells(1, 26) - 2 - j)), 7 - i)
Else
If i < 6 Then
cc = i + 1
Cells(j + 2, i).FormulaR1C1 = Application.WorksheetFunction.Large(Sheets(1).Range("C" & Application.WorksheetFunction.Count(Sheets(1).Columns(9)) - (Cells(1, 26) - 2 - j) & ":H" & Application.WorksheetFunction.Count(Sheets(1).Columns(9)) - (Cells(1, 26) - 2 - j)), 7 - cc)
Else
Cells(j + 2, i).FormulaR1C1 = Application.WorksheetFunction.Index(Sheets(1).Columns(9), Application.WorksheetFunction.Count(Sheets(1).Columns(9)) - (Cells(1, 26) - 2 - j))
End If
End If
End If
End If
Next
Next
If Cells(1, 12) = 1 Or Cells(1, 19) = 7 Then
With ActiveSheet.Range("G4")
For i = 1 To Cells(1, 26) - 1
.Cells(i, 1).Value = Application.WorksheetFunction.Index(Sheets(1).Columns(Cells(1, 19) + 2), Application.WorksheetFunction.Count(Sheets(1).Columns(Cells(1, 19) + 2)) - (Cells(1, 26) - 3 - i))
Next
End With
Else
With ActiveSheet.Range("G4")
For i = 1 To Cells(1, 26)
.Cells(i, 1).Value = Application.WorksheetFunction.Large(Sheets(1).Range("C" & Application.WorksheetFunction.Count(Sheets(1).Columns(9)) - (Cells(1, 26) - 3 - i) & ":H" & Application.WorksheetFunction.Count(Sheets(1).Columns(9)) - (Cells(1, 26) - 3 - i)), 7 - Cells(1, 19))
Next
End With
End If
End If
Range("A1").Select
Application.ScreenUpdating = True
End Sub |