选择范围从3到2到最后一行运行时错误13:类型不匹配? [英] Select range between 3rd and 2nd to last row Runtime error 13: Type mismatch?
本文介绍了选择范围从3到2到最后一行运行时错误13:类型不匹配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试编写一个首先找到最后一行的代码,并选择第2行到第3行之间的所有行。然后继续删除它们。但是我不断遇到错误13:类型不匹配
I'm trying to write a code that first find the last row, and selects all rows between the 2nd to last row and the 3rd row. Then proceeds to delete them. But I keep running into an error 13 : Type mismatch
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形式的行索引(例如)。你传递一个字符串StartRow:NuRow。
It is the Rows object that is throwing the error. It is expecting a row Index in the form "3:20" (for example). You are passing it a string "StartRow:NuRow".
尝试将该语句更改为:
Rows(StartRow & ":" & NuRow).Delete
这篇关于选择范围从3到2到最后一行运行时错误13:类型不匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文