Reputation: 363
Why does this work:
Set rowNonBlankFound = Rows(rowToUse).Find(what:="*", after:=Cells(rowToUse, leftMostCol), LookIn:=xlValues, SearchDirection:=xlNext)
But this doesn't:
Dim direction As String
direction = "xlNext"
Set rowNonBlankFound = Rows(rowToUse).Find(what:="*", after:=Cells(rowToUse, leftMostCol), LookIn:=xlValues, SearchDirection:=direction)
I get run-time error 13 - type mismatch?
Upvotes: 0
Views: 27
Reputation: 8531
Direction is an enumeration enter link description here needs to be a number or an enumeration equiv
Upvotes: 0
Reputation: 3188
SearchDirection
is not a argument of type String
, but of type XlSearchDirection
, you cannot pass a string to it since there is no convertion from one to the other.
xlNext
is not identical to "xlNext"
Use following code:
Dim direction As XlSearchDirection
direction = xlNext
Set rowNonBlankFound = Rows(rowToUse).Find(what:="*", after:=Cells(rowToUse, leftMostCol), LookIn:=xlValues, SearchDirection:=direction)
Upvotes: 1