这个性能问题让我抓狂:(。
我的目的是复制n
行并将其n
次粘贴到同一张表格中。
我的代码如下所示:
Public Sub InsertRows(ByVal pCopyFrom As Integer, ByVal pCopyTo As Integer _
, ByVal pStart As Integer, ByVal pCount As Integer)
If pCount <= 0 Then
Exit Sub
End If
Dim xlRange1 As Excel.Range
xlRange1 = _sheet.Range(CStr(pCopyFrom) + ":" + CStr(pCopyTo))
xlRange1.Copy()
Dim xlPasteRange As Excel.Range = _sheet.Range(CStr(pStart) + ":" + CStr(pStart + pCount * (pCopyTo - pCopyFrom + 1) - 1))
xlPasteRange.Insert()
End Sub
问题是,当我这样称呼时,这将需要长达10分钟:
InsertRows(8, 9, 10, 13000) -- 13000 is the data source row count
是否有任何建议让它跑得更快?