whitehawk81
Board Regular
- Joined
- Sep 4, 2016
- Messages
- 66
Hi,
I'm trying to create a keyword search function, that uses a named range called "kwmap". It creates a string array from the found keywords and maps them with vlookup to the corresponding number (solution ID). After that it should compare the amounts of each ID and set the result to the ID with the highest count. But unfortunately I'm stuck by the step, when I try to pass the vlookup result to the array items.
This is the code I wrote so far:
I get a VALUE error and it seems to have a problem with my named range, though I don't know why.
I'm trying to create a keyword search function, that uses a named range called "kwmap". It creates a string array from the found keywords and maps them with vlookup to the corresponding number (solution ID). After that it should compare the amounts of each ID and set the result to the ID with the highest count. But unfortunately I'm stuck by the step, when I try to pass the vlookup result to the array items.
This is the code I wrote so far:
Code:
Function Kwrd(Words As Range, strText As Range)Dim c As Range
For Each c In Words
If InStr(1, strText, c, 1) > 0 Then Kwrd = Kwrd & "," & c
Next c
If Kwrd = 0 Then
Kwrd = "-"
Else
Kwrd = Right(Kwrd, Len(Kwrd) - 1)
mapKw Kwrd
End If
End Function
Sub mapKw(ByVal Kwrd As String)
Dim wb As Workbook
Dim SolNum As Variant
Dim myArray() As String
Dim solArray() As Long
Dim myRange As Range
myRange = wb.Worksheets("Legend").Range("kwmap")
myArray = Split(Kwrd, ",")
ReDim myArray(1 To UBound(myArray))
For i = 1 To UBound(myArray)
'non of these seem to work
myArray(i) = Evaluate("VLOOKUP(myArray(i), myRange, 2, False)")
'myArray(i)= Application.WorksheetFunction.VLookup(myArray(i), myRange, 2, False)
'pass array items to integer array
'solArray(i) = myArray(i)
Next i
End Sub
I get a VALUE error and it seems to have a problem with my named range, though I don't know why.