查找 – 在SearchDirection中放置variables会导致运行时错误13 – types不匹配
为什么这个工作:
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 – types不匹配?
SearchDirection
不是String
types的参数,而是XlSearchDirection
types的XlSearchDirection
,因为不存在从一个到另一个的转换,所以不能将string传递给它。 xlNext
与"xlNext"
不一样
使用以下代码:
Dim direction As XlSearchDirection direction = xlNext Set rowNonBlankFound = Rows(rowToUse).Find(what:="*", after:=Cells(rowToUse, leftMostCol), LookIn:=xlValues, SearchDirection:=direction)
方向是一个枚举input链接描述这里需要是一个数字或枚举equiv