Dim finishedStartRow As Long
Rows("finishedStartRow:finishedStartRow").Select
我试图使用finishedStartRow变量选择行481805。我收到类型不匹配错误,因为.Select只能处理整数。有解决方法吗?谢谢!
答案 0 :(得分:2)
dim'med var不应包含在引号中。
Dim startStartRow As Long
Dim finishedStartRow As Long
startStartRow = 2
finishedStartRow = 481805
'all of these are valid for variations on selection¹
Rows(finishedStartRow).Select
Rows(finishedStartRow & ":" & finishedStartRow).Select
Rows(startStartRow & ":" & finishedStartRow).Select
¹有关远离依赖选择和激活以实现目标的更多方法,请参阅How to avoid using Select in Excel VBA macros。