habe das folgende Set-up:
Wortliste - Punkte
Wort 1 - 1
Wort 2 - 2
Wort 3 - 3
Wort 4 - 4
Text-Zelle - Wörter aus Wortliste - Punkte aus Wortliste
Text mit mehreren Wörtern - CountWortListe - AddWordScore
So, ich möchte jetzt:
1. Zählen wie oft in dem Text Wörter aus der Wortliste vorkommen
2. Wie die gesamte Score wäre (also wenn 2x Wort 1 vorkommt und 1x Wort 2 --> 2x1+2 = 4
Für 1. verwende ich folgende Funktion:
Function CountWortListe(Satz As String, Wortliste As Range) As Integer
Dim c As Range
For Each c In Wortliste
If InStr(Satz, c) > 0 Then
CountWortListe = CountWortListe + 1
End If
Next
End Function
2)
Hatte mir für die Score folgendes ausgedacht (zusätzlich noch Score als Range über die _ Wortliste + Score):
Function AddWordScore(Satz As String, Wortliste As Range, Score As Range) As Integer
Dim c As Range
For Each c In Wortliste
If InStr(Satz, c) > 0 Then
AddWordScore = AddWordScore + Application.WorksheetFunction.Vlookup(c, Score, 2, False)
End If
Next
End Function
Das scheint allerdings so nicht zu funktionieren. Hätte jemand einen Vorschlag wie ich den zweiten Teil ändern könnte?
Vielen Dank schon einmal!