PDA

View Full Version : [SOLVED:] Find and color text with Text List



Ethen5155
03-24-2018, 07:26 AM
Hi all,

i'm seeking to find a macro way that can go through excel file with many segments with name for ex. (Project) then color all words inside all cells according to another excel file defined previously for ex. (keywords)

for ex

Project file contains cells as following:

1- Check out the examples of abstract nouns
2- Active voice describes a sentence where the subject
3- Comparative adjectives are used to compare


keywords file contains words as following:

abstract nouns
subject
Comparative adjectives
......etc


so i want to color only words (abstract nouns, subject, Comparative adjectives) from Project file

21906


Thanks i advance for helping



Cross-Posting: https://www.excelforum.com/excel-programming-vba-macros/1225318-find-and-color-text-with-text-list.html#post4870362

Ethen5155
03-24-2018, 01:44 PM
Solved:

by tim201110 (https://www.excelforum.com/members/254916.html) :


Sub kewd()
Dim lr&, i&, j&
ka = Application.Transpose(Range("_k"))
lr = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To lr
For j = 1 To UBound(ka)
If InStr(StrConv(Cells(i, 1), vbLowerCase), ka(j)) > 0 Then
Cells(i, 1).Characters(Start:=InStr(StrConv(Cells(i, 1), vbLowerCase), ka(j)), Length:=Len(ka(j))).Font.Color = -16776961
End If
Next j
Next i
End Sub