编译错误“End With With With”

对于下面的代码,我不断收到编译错误:“结束与无”

Sub Copy_Swivel_To_MIM_DATA() Application.ScreenUpdating = False With ActiveWorkbook.Worksheets("Swivel") .Columns("AC:AC").EntireColumn.Copy Destination:=Sheets("MIM Data").Range("A1") .Columns("J:J").EntireColumn.Copy Destination:=Sheets("MIM Data").Range("B1") .Columns("K:K").EntireColumn.Copy Destination:=Sheets("MIM Data").Range("C1") .Columns("L:L").EntireColumn.Copy Destination:=Sheets("MIM Data").Range("D1") .Columns("M:M").EntireColumn.Copy Destination:=Sheets("MIM Data").Range("E1") .Columns("N:N").EntireColumn.Copy Destination:=Sheets("MIM Data").Range("F1") .Columns("O:O").EntireColumn.Copy Destination:=Sheets("MIM Data").Range("G1") .Columns("P:P").EntireColumn.Copy Destination:=Sheets("MIM Data").Range("H1") .Columns("Q:Q").EntireColumn.Copy Destination:=Sheets("MIM Data").Range("I1") .Columns("F:F").EntireColumn.Copy Destination:=Sheets("MIM Data").Range("J1") End With With ActiveWorkbook.Worksheets("MIM Data") .Columns("A:J").EntireColumn.Hidden = False End With With ActiveWorkbook.Worksheets("MIM Data").Sort With .SortFields .Clear .Add Key:=Range("A2:A2000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal .Add Key:=Range("G2:G2000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal .Add Key:=Range("B2:B2000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal .Add Key:=Range("C2:C2000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal .Add Key:=Range("D2:D2000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal .Add Key:=Range("E2:E2000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal End With .SetRange Range("A2:AE2000") .Apply End With Worksheets("MIM QA").Columns("A:J").AutoFit With Sheets("MIM Data").Range("A2:AA2000") With .Font .name = "Arial" .FontStyle = "Regular" .Size = 10 .Color = RGB(0, 0, 255) End With End With With ActiveWorkbook.Worksheets("MIM Data") Dim DelAftDis As Long For DelAftDis = Cells(Rows.Count, 10).End(xlUp).row To 2 Step -1 With Cells(DelAftDis, 10) If .Value = "After Dispute For SBU" Then Rows(DelAftDis).EntireRow.Delete End With Next DelAftDis End With Application.ScreenUpdating = True Range("A" & Rows.Count).End(xlUp).Offset(1).Select End Sub 

我不明白错误消息,因为每个With有一个关联End With 。 指出的问题是这些:

 With ActiveWorkbook.Worksheets("MIM Data") Dim DelAftDis As Long For DelAftDis = Cells(Rows.Count, 10).End(xlUp).row To 2 Step -1 With Cells(DelAftDis, 10) If .Value = "After Dispute For SBU" Then Rows(DelAftDis).EntireRow.Delete End With ' <--- This is highlighted by the debugger Next DelAftDis End With 

我错过了一个“ End With吗? 如果是的话,它应该放在哪里?

您似乎缺less一行“结束如果”的代码行:

 If .Value = "After Dispute For SBU" Then 

在最后加上一个“End if”如下:

 With Cells(DelAftDis, 10) If .Value = "After Dispute For SBU" Then Rows(DelAftDis).EntireRow.Delete End if End With