5 pts.
 finding words within other words with an Excel macro
column B has 2 letter words, the next 3 then 4 and so forth. I am looking to find the words in each column to the right to find all of theentrie that contain it and change the color of only the 2 or 3 or 4... letters in the new word for all words in each of the colomns to the right. Example: AA would find AAH, AAL, BAA, BAAL, BAASKAAP, ETC. 78 words total. the 2 letter words in column B could make the letters BLUE in the other columns and the 3 letter words GREEN in the other column and a different color for each column. Therre are 14 columns of words with 300,000 word combinations. I am looking for those smaller words within the larger words.

Software/Hardware used:
ASKED: September 19, 2008  5:59 PM
UPDATED: September 20, 2008  9:26 PM

Answer Wiki:
It took me a few minutes but this Excel macro should do the trick for you. Bascially it's going to go row by row, for all the columns and see if the values exist in any of the values in the columns to the right. Each source column should get a different column. <pre> Dim i As Integer, j As Integer, Word As String, Col As Integer, SourceCol As Integer i = 1 SourceCol = 65 Do Until Range(Chr(SourceCol) & 1).Value = "" i = 1 Do Until Range(Chr(SourceCol) & i).Value = "" Word = Range(Chr(SourceCol) & i).Value j = 1 Col = 66 Do Until Range(Chr(Col) & j).Value = "" j = 1 Do Until Range(Chr(Col) & j).Value = "" Range(Chr(Col) & j).Select If InStr(Range(Chr(Col) & j).Value, Word) <> 0 Then Range(Chr(Col) & j).Select With Selection.Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .ColorIndex = SourceCol - 60 .TintAndShade = 0 .PatternTintAndShade = 0 End With End If j = j + 1 Loop Col = Col + 1 j = 1 Loop i = i + 1 Loop SourceCol = SourceCol + 1 Loop</pre>
Last Wiki Answer Submitted:  September 20, 2008  9:26 pm  by  Denny Cherry   64,505 pts.
All Answer Wiki Contributors:  Denny Cherry   64,505 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _