当Excel工作表原始数据的行数低于10,000行时,当它有10,000行时,我就会收到错误。任何的想法?该错误指向mu = Cells(joker, 12)
Columns("A:I").Select
Selection.ClearContents
Windows("New Registrations.xls").Activate
ActiveWindow.WindowState = xlNormal
Columns("A:I").Select
Selection.Copy
Windows("Polk Trend Report CYTD.xlsm").Activate
Range("A1").Select
ActiveSheet.Paste
Selection.Interior.ColorIndex = xlNone
Selection.Font.ColorIndex = 0
Sheets("Data").Select
Dim nz As Long
Dim joker As Long
Dim lambda As Long
nz = Cells(4, 12).Value
Dim mu As Long
For joker = 5 To nz + 4
lambda = Cells(joker, 11)
mu = Cells(joker, 12)
If lambda <> 0 And mu - lambda > 1 Then
Range("A" & lambda).Select
Selection.Copy
Range("A" & lambda + 1 & ":A" & mu - 1).Select
ActiveSheet.Paste
Else:
End If
Next joker
Range("N5:O" & nz + 4).Select
Selection.ClearContents
Dim iota As Long
Dim kappa As Long
iota = 7
Do While Cells(iota, 2).Value <> ""
If Cells(iota, 2) = "UNKNOWN" Then
kappa = Application.WorksheetFunction.Match(Cells(iota, 1).Value, Range("J1:J" & nz + 4), 0)
Cells(kappa, 14).Value = Cells(iota, 7).Value
Cells(kappa, 15).Value = Cells(iota, 5).Value
Range("A" & iota & ":I" & iota).Select
Selection.Delete Shift:=xlUp
iota = iota - 1
ElseIf Cells(iota, 2) = "Zone Total" Then
Range("A" & iota & ":I" & iota).Select
Selection.Delete Shift:=xlUp
iota = iota - 1
ElseIf Application.WorksheetFunction.And(Cells(iota, 5) = 0, Cells(iota, 7) = 0) Then
Range("A" & iota & ":I" & iota).Select
Selection.Delete Shift:=xlUp
iota = iota - 1
Else:
End If
iota = iota + 1
Loop
Range("A" & iota & ":I" & iota).Select
Selection.Delete Shift:=xlUp
Range("C5:I5").Select
Selection.Copy
Range("C6").Select
ActiveSheet.Paste
Set pvtTable = Worksheets("Total Dealer (Trend)").Range("O5").PivotTable
pvtTable.RefreshTable
Sheets("Total Dealer (Trend)").Select
Cells.Select
Selection.Columns.AutoFit
Sheets("Data").Select
Range("S40:T" & nz + 39).Select
Selection.Copy
Range("A2").Select
Sheets("Total Dealer (Trend)").Select
Range("B40").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Sheets("Data").Select
Range("U40:U" & nz + 39).Select
Selection.Copy
Range("A2").Select
Sheets("Total Dealer (Trend)").Select
Range("E40").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("B40:E" & nz + 39).Select
Selection.Sort Key1:=Range("E40"), Order1:=xlDescending, Header:=xlNo _
, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A1").Select
ActiveWindow.WindowState = xlMaximized
End Sub
答案 0 :(得分:0)
我认为您可能会在10,000行后的工作表上进行格式更改。假设这是一个约会,现在它是一般的或其他类型的冲突,并且由于mu的值被设置,你得到的数据不匹配 &#34; L10000&#34;
检查10,000以下单元格的格式。特别是专栏&#34; L&#34;
答案 1 :(得分:0)
这是一个示例错误处理程序,希望您可以按照描述将其复制并粘贴到您的代码中,它应该在错误发生时输出失败单元格的值,然后您可以希望纠正它。以下内容位于代码顶部
On Error GoTo MyProcedure_Error
然后,下面超过了结束子
MyProcedure_Exit:
On Error GoTo 0
Exit Sub
MyProcedure_Error:
Select Case Err.Number
'the "Case 9" statement below is left as an example to show how you could code a
'specific error message if a specifc module needed it
'Case 9
'MsgBox "The input file does not appear to be in the correct format, for importing into the " & _
'" Locations tab" & vbCrLf & "The expected format is " & Str(Import_Cols) & " columns, Pipe Delimited" & _
'vbCrLf, vbCritical, "Error in in procedure TrimColumn of Module DeveloperToolKit"
Case Else
MsgBox "An unexpected error has occured, the call value that has failed is." & _
vbCrLf & Cells(joker, 12) & _
vbCrLf & "Error Code = " & Str$(Err.Number) & _
vbCrLf & "Error Text = " & Err.Description, vbCritical, "Critical Error"
End Select
Resume MyProcedure_Exit