所以我有一个代码通过电子表格(大约150,000行)并突出显示特定的红色。现在,我正在尝试移动那些选定的行,这是我的代码:
Dim x As Long, iInsertedRows As Integer
x = Range("A1").End(xlDown).Row
For x = x To 1 Step -1
If Cells(x, 1).Interior.ColorIndex = 3 Then '3 is standard red color
Rows(x).Cut
'''The next row is where it breaks'''
Rows("1:1").Insert shift:=xlDown 'paste the cut row back as row 1
x = x + 1 'we've just moved everything down a row
iInsertedRows = iInsertedRows + 1
If iInsertedRows = x Then Exit For 'we don't need to sort the ones we put there
End If
Next
(资料来源:http://p2p.wrox.com/excel-vba/6791-move-rows-top-cells-columna-filled-red.html)
问题是我收到的错误如下: 运行时错误'1004': 此选择无效。 有几个可能的原因: