Re: June/July 2008 Challenge of the Month
I know I'm a few months too late, but I just checked the board for the first time in ages (I was bored). I had a go, and then saw everyone else's entries. But here's my sorrt attempt:
Sub theChallenge()
Dim countKeywords As Integer
Dim countPhrases As Integer
Dim i As Integer
Dim j As Integer
Dim theWords
Dim thePhrases
countKeywords = Range(Cells(2, 4), Cells(2, 4).End(xlDown)).Rows.count
countPhrases = Range(Cells(2, 1), Cells(2, 1).End(xlDown)).Rows.count
ReDim theWords(countKeywords, 2) As Variant
ReDim thePhrases(countPhrases) As String
Worksheets("Sheet1").Select
For i = 1 To countPhrases
thePhrases(i) = Cells(i + 1, 1)
Next i
For i = 1 To countKeywords
For j = 1 To 2
theWords(i, j) = Cells(i + 1, j + 3)
Next j
Next i
For i = 1 To countPhrases
For j = 1 To countKeywords
If InStr(1, thePhrases(i), theWords(j, 1), 1) > 0 Then
Cells(i + 1, 2) = theWords(j, 2)
End If
Next j
Next i
End Sub
I know I'm a few months too late, but I just checked the board for the first time in ages (I was bored). I had a go, and then saw everyone else's entries. But here's my sorrt attempt:
Sub theChallenge()
Dim countKeywords As Integer
Dim countPhrases As Integer
Dim i As Integer
Dim j As Integer
Dim theWords
Dim thePhrases
countKeywords = Range(Cells(2, 4), Cells(2, 4).End(xlDown)).Rows.count
countPhrases = Range(Cells(2, 1), Cells(2, 1).End(xlDown)).Rows.count
ReDim theWords(countKeywords, 2) As Variant
ReDim thePhrases(countPhrases) As String
Worksheets("Sheet1").Select
For i = 1 To countPhrases
thePhrases(i) = Cells(i + 1, 1)
Next i
For i = 1 To countKeywords
For j = 1 To 2
theWords(i, j) = Cells(i + 1, j + 3)
Next j
Next i
For i = 1 To countPhrases
For j = 1 To countKeywords
If InStr(1, thePhrases(i), theWords(j, 1), 1) > 0 Then
Cells(i + 1, 2) = theWords(j, 2)
End If
Next j
Next i
End Sub