Excel 2016插入副本的单元格速度非常慢

我有一个相当大的表(约60K行,50列)。 我试图将几个(2到8)行复制到剪贴板,然后插入复制的单元格。 这个操作需要一分多钟才能完成!

我已经尝试禁用自动计算,从VBA启动此操作,如下所示:

Range("A1").Insert xlShiftDown 

到没有可用。 如果我粘贴(Ctrl-V)而不是插入它就像一个快照。

任何想法如何解决这个问题?

既然你可以足够快地粘贴数据,而不是插入,然后对行进行sorting:

  1. 在第一行数据的空列中键入要插入的行数加1(例如,插入3行types4)
  2. 在下一行中添加下一个数字,然后select两个单元格并自动填充列,以便每一行的数量都在增加
  3. 将新数据粘贴到旧数据的末尾,紧跟在最后一行之后
  4. 第一行粘贴为1,第二行粘贴为2等
  5. 在数字列上对表单进行sorting,然后删除该列

我实现了Absinthe的algorithm,下面是代码:

  Sub InsertRows() Dim SourceRange, FillRange As Range Dim LastCol, LastRow, ActRow, CpdRows As Long Dim i As Integer If Application.CutCopyMode <> xlCopy Then Exit Sub Application.ScreenUpdating = False Application.EnableEvents = False With ActiveSheet LastCol = .UsedRange.Columns.Count LastRow = .UsedRange.Rows.Count ActRow = ActiveCell.Row .Paste Destination:=.Cells(LastRow + 1, 1) CpdRows = .UsedRange.Rows.Count - LastRow Application.Calculation = xlCalculationManual Set SourceRange = .Range(.Cells(ActRow, LastCol + 1), .Cells(ActRow + 1, LastCol + 1)) SourceRange.Cells(1).Value = CpdRows + 1 SourceRange.Cells(2).Value = CpdRows + 2 Set FillRange = .Range(.Cells(ActRow, LastCol + 1), .Cells(LastRow, LastCol + 1)) SourceRange.AutoFill Destination:=FillRange For i = 1 To CpdRows .Cells(LastRow + i, LastCol + 1).Value = i Next i .Range(.Cells(ActRow, 1), .Cells(LastRow + CpdRows, LastCol + 1)).Sort Key1:=.Cells(ActRow, LastCol + 1), _ Order1:=xlAscending, Header:=xlNo, MatchCase:=False, Orientation:=xlTopToBottom .Columns(LastCol + 1).Delete End With Application.Calculation = xlCalculationAutomatic Application.EnableEvents = True Application.ScreenUpdating = True End Sub