从第3行到第2行到最后一行之间select范围运行时错误13:types不匹配?

我想写一个代码,首先find最后一行,并select第二行到最后一行和第三行之间的所有行。 然后继续删除它们。 但我不断遇到错误13:types不匹配

Dim StartRow, LastRow, NuRow As Variant StartRow = 3 Sheets("Sheet3").Activate If WorksheetFunction.CountA(Cells) > 0 Then 'Search for any entry, by searching backwards by Rows. LastRow = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row End If NuRow = LastRow - 1 Rows("StartRow:NuRow").Delete 'Run time error 13 Type Mismatch 

有任何想法吗 ?

抛出错误的是Rows对象。 期望以“3:20”forms的行索引(例如)。 你传递一个string“StartRow:NuRow”。

尝试将该语句更改为:

 Rows(StartRow & ":" & NuRow).Delete 

试试这个:

 Rows(StartRow & ":" & NuRow).Delete