|
Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Application.ScreenUpdating = False
Dim i As Long
Dim cpxx, X, Y
If ListBox1.ListIndex <= 0 Then Exit Sub
X = ActiveCell.Row
Cells(X, "C") = CStr(ListBox1.List(ListBox1.ListIndex, 3))
Cells(X, "D") = CStr(ListBox1.List(ListBox1.ListIndex, 4))
Cells(X, "E") = CStr(ListBox1.List(ListBox1.ListIndex, 5))
Cells(X, "F") = CStr(ListBox1.List(ListBox1.ListIndex, 6))
Cells(X, "G") = CStr(ListBox1.List(ListBox1.ListIndex, 7))
Cells(X, "H") = CStr(ListBox1.List(ListBox1.ListIndex, 8))
Cells(X, "I") = CStr(ListBox1.List(ListBox1.ListIndex, 9))
CP_EDROW = Sheet1.Range("B" & Sheet1.Rows.Count).End(xlUp).Row
cpxx = Sheet1.Range("A2:H" & CP_EDROW)
Dim chaDanHao As String
chaDanHao = UCase(Trim(CStr(Cells(X, "C"))))
Cells(X, 23) = "=C" & X & "&G" & X
For i = 1 To CP_EDROW - 1
If (UCase(Trim(CStr(cpxx(i, 1)))) = chaDanHao) Then
Cells(X, 10) = CStr(cpxx(i, 5))
Cells(X, 11) = cpxx(i, 6)
Cells(X, 12) = cpxx(i, 7)
Cells(X, 13) = cpxx(i, 8)
Cells(X, 14) = "=H" & X & "*M" & X
X = X + 1
End If
Next i
X = ActiveCell.Row
Y = Sheet3.Range("J" & Sheet3.Rows.Count).End(xlUp).Row
Range("D" & X & ":I" & X).Select
Selection.Copy
Range("D" & X & ":I" & Y).Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("C" & Y + 1).Select
Unload Me
'
Application.ScreenUpdating = True
End Sub
同样的代码,在只有几个工作表的时候运行很快,但工作表有十几个的时候就很慢,要如何解决?谢谢
|
|