Re: June/July 2008 Challenge of the Month
I'm new to the VB/computer programming thing...judging from the entries, I imagine I could have done this 10 times more efficiently (if I knew how). I'm learning a ton though!!!
Public Function colorfun(x As String)
Dim phraselettercount As Integer
Dim keyword_assignedto(9, 2) As String
Dim col As Integer
Dim wordcount As Integer
Dim wordstart As Integer
Dim rollingword As String
phraselettercount = Len(x)
wordstart = 1
col = 1
row1 = 1
x = Trim(x)
For i = 1 To 18
If i <= 9 Then
keyword_assignedto(i, col) = Range("D" & i + 1).Value
Else
If col = 1 Then
col = col + 1
End If
keyword_assignedto(i - 9, col) = Range("E" & i - 9 + 1).Value
End If
Next i
col = 1
For Z = 1 To phraselettercount + 1
If Mid(Trim(x), wordstart, 1) <> " " And wordstart < Len(x) + 1 Then
rollingword = rollingword & Mid(x, wordstart, 1)
wordstart = wordstart + 1
Else
For p = 1 To 9
If rollingword = keyword_assignedto(p, col) Then
colorfun = keyword_assignedto(p, col + 1)
End If
Next p
wordstart = wordstart + 1
rollingword = ""
End If
Next Z
End Function