2016-10-29 1 views

답변

0

이 코드를 사용하여 키워드를 강조 표시 할 수 있습니다. 이 코드는 선택한 범위를 검색하고 단어 색상을 변경하여 작동합니다.

End If 코드의 첫 부분을 추가하고 텍스트를 변경할 수 있습니다. 행운을 빈다!

Private Sub Worksheet_Change(ByVal Target As Range) 

    Set myRange = Range("A1:AG100") 'The Range that contains the substring you want to change color 
    substr = "t" 'The text you want to change color 
    txtColor = 3 'The ColorIndex which represents the color you want to change 


    For Each myString In myRange 
     lenstr = Len(myString) 
     lensubstr = Len(substr) 
     For i = 1 To lenstr 
      tempString = Mid(myString, i, lensubstr) 
      If tempString = substr Then 
       myString.Characters(Start:=i, Length:=lensubstr).Font.ColorIndex = txtColor 
      End If 
     Next i 
    Next myString 

    Set myRange = Range("A1:AG100") 'The Range that contains the substring you want to change color 
    substr = "u" 'The text you want to change color 
    txtColor = 4 'The ColorIndex which represents the color you want to change 
     For Each myString In myRange 
     lenstr = Len(myString) 
     lensubstr = Len(substr) 
     For i = 1 To lenstr 
      tempString = Mid(myString, i, lensubstr) 
      If tempString = substr Then 
       myString.Characters(Start:=i, Length:=lensubstr).Font.ColorIndex = txtColor 
      End If 
     Next i 
    Next myString 
End Sub