EXCEL VBA如何更改一个IF(循环)的其他东西?

我有这个代码的工作,但它需要很多时间,我确定有一种方法来优化它我做了一些研究,但我无法find如何。 我的文件真的很大(100MB +),所以任何使这个代码更快的必要。

lastrowLaneTemplate = Sheets("LaneTemplate").Range("A65536").End(xlUp).Row lastrowCarrier = Sheets("Routed").Range("B65536").End(xlUp).Row lastrowCarrierd = Sheets("Routed").Range("B65536").End(xlUp).Row j = 2 For i = 10 To lastrowLanetemplate For z = 2 To lastrowCarrier If Sheetlanetemplate.Cells(i, 4).Value <> "" Then If Sheetlanetemplate.Cells(i, 4) = sheetCarrier.Cells(z, 1) And _ sheetCarrier.Cells(z, 3) = "1" Then sheetcarrierd.Cells(j, 1) = sheetCarrier.Cells(z, 1) sheetcarrierd.Cells(j, 2) = sheetCarrier.Cells(z, 2) sheetcarrierd.Cells(j, 3) = sheetCarrier.Cells(z, 3) sheetcarrierd.Cells(j, 4) = sheetCarrier.Cells(z, 4) sheetcarrierd.Cells(j, 5) = sheetCarrier.Cells(z, 5) sheetcarrierd.Cells(j, 6) = sheetCarrier.Cells(z, 6) sheetcarrierd.Cells(j, 7) = sheetCarrier.Cells(z, 7) sheetcarrierd.Cells(j, 8) = sheetCarrier.Cells(z, 8) sheetcarrierd.Cells(j, 9) = sheetCarrier.Cells(z, 9) sheetcarrierd.Cells(j, 10) = sheetCarrier.Cells(z, 10) sheetcarrierd.Cells(j, 11) = sheetCarrier.Cells(z, 11) j = j + 1 End if Next z Next y 

正如你所看到的那样,但它需要一些时间,我有10倍。所以,如果有一种方法来做到这一点没有IF将是完美的

我的快速的想法是改变11行, if...end if语句成一行:

 sheetcarrierd.Range(sheetcarrierd.Cells(j, 1), sheetcarrierd.Cells(j, 11)).Value = _ sheetCarrier.Range(sheetCarrier.Cells(Z, 1), sheetCarrier.Cells(Z, 11)).Value 

但我不确定是否会显着提高性能。

你已经在使用这些了吗?

开始时:

 Application.Calculation = xlCalculationManual Application.ScreenUpdating = False 

最后:

 Application.Calculation = xlCalculationAutomatic Application.ScreenUpdating = True