I am trying to find a string that lies in a specific column a different sheet (in this case, name is "Company"). This is what I wrote ("CompanyName" is the search string):
Public Function GetCompanyNumber(CompanyName) As String
ThisWorkbook.Worksheets("Company").Select
Range("B:B").Select
GetCompanyNumber = Selection.Find(What:=CompanyName, After:=[A1], LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Address
End Function
However, every time it fails with Select method range class failed
and returns me to line Range("B:B").Select
. I have written this so that my search is only limited to the column B (preferably within cell number B20). How can I fix this?
Thanks.
If it maters, the search string contains special characters like ö