为什么这样做:
Set rowNonBlankFound = Rows(rowToUse).Find(what:="*", after:=Cells(rowToUse, leftMostCol), LookIn:=xlValues, SearchDirection:=xlNext)
但这并不是:
Dim direction As String
direction = "xlNext"
Set rowNonBlankFound = Rows(rowToUse).Find(what:="*", after:=Cells(rowToUse, leftMostCol), LookIn:=xlValues, SearchDirection:=direction)
我得到运行时错误13 - 类型不匹配?
答案 0 :(得分:1)
SearchDirection
不是String
类型的参数,而是XlSearchDirection
类型的参数,因为没有从一个转换到另一个,所以不能将字符串传递给它。
xlNext
与"xlNext"
使用以下代码:
Dim direction As XlSearchDirection
direction = xlNext
Set rowNonBlankFound = Rows(rowToUse).Find(what:="*", after:=Cells(rowToUse, leftMostCol), LookIn:=xlValues, SearchDirection:=direction)
答案 1 :(得分:0)
方向是枚举enter link description here需要是数字或枚举等效