0

I have tried to implement some vectorization in my code which seeks for relevant row (to classify some data). Unfortunately it seems like range in find (stored within "with" method) does not accept range as column and concatenated row number as int.

With range set as ("B:B") it works (code below):

With AllPlatformsProductsCostsTATMatrixwb.Sheets(platform)
            finalrow = .Range("B:B").Find(what:=country).row
            FindMatch2criteria = finalrow
End With

With range set as ("B" & rownumber) it does not work (code below):

With AllPlatformsProductsCostsTATMatrixwb.Sheets(platform)
            finalrow = .Range(Range("B" & startrow), Range("B" & endrow)).Find(what:=country).row
            FindMatch2criteria = finalrow
        End With

Any ideas?

  • 2
    Put the period in front of the ranges inside the parentheses – Scott Craner May 20 '22 at 13:28
  • Your code assumes that the `Find` succeeded, by chaining a `.Row` to it. Better practice is to first [test if the Find succeeded](https://stackoverflow.com/questions/1589939/how-to-detect-whether-vba-excel-found-something), – BigBen May 20 '22 at 13:33
  • See [vba dot notation](https://stackoverflow.com/questions/41860149/vba-dot-notation) – Cyril May 20 '22 at 13:34

0 Answers0