请尝试下一个方法:
Sub TestInsertRow()
Dim sh, arr, arrInsR, arrFin
Set sh = ActiveSheet
arr = sh.[A1:C5].Value 'array to insert a row
arrInsR = sh.[A11:C11].Value 'row to be inserted
arrFin = InsertRowElab(arr, arrInsR, 3) 'inserted row to be the third
sh.[J10].Resize(UBound(arrFin), UBound(arrFin, 2)).Value = arrFin
End Sub
Private Function InsertRowElab(arr As Variant, arrIns As Variant, insRowNo As Long) As Variant 'it inserts a row
Dim i&, k&, Ar, arrR, arrRows, arrCols
arrR = Application.Transpose(Application.Evaluate("row(1:" & UBound(arr) & ")")) 'build the rows array
Debug.Print "Joined rows array: " & Join(arrR, "#"): 'so the joined array looks
arrRows = Split(Replace(Join(arrR, "|"), insRowNo - 1 & "|", insRowNo - 1 & "|0|"), "|") 'insert the row, placing 0 in the array
Debug.Print "Joined rows array containing the inserted row (0): " & Join(arrRows, "#") 'so the joined array containing the new row (0) looks
arrCols = Application.Transpose(Application.Evaluate("row(1:" & UBound(arr, 2) & ")")) 'Array(1, 2, 3)
Ar = Application.Index(arr, Application.Transpose(arrRows), arrCols)
'fill the inserted row:
For i = LBound(Ar) To UBound(Ar, 2): Ar(insRowNo, i) = arrIns(1, i): Next i
InsertRowElab = Ar
End Function