Snowhare
엑셀 vba 셀의 특정 텍스트 찾아 색깔 설정 본문
엑셀 vba 셀의 특정 텍스트 찾아 색깔 설정
엑셀 셀안의 텍스트의 특정 단어나 문장을 색으로 표시해서 잘 보이게 하고 싶습니다. 엑셀 매크로를 조금 아신다면...
sub findStrColor()
dim strTest as String
dim strLen as String
dim pos as Integer
strTest = "single failure" ' 색을 입히려는 단어
strLen = Len(strTest)
For Each cell in Selection ' 선택한 셀 범위에서 변경
pos = Intr(1, cell, strTest, 1) ' 대소문자 구분하려면, 마지막의 1을 0으로
if (pos > 0) Then
cellLen = Len(cell.Text)
Do
cell.Characters(pos, strLen).Font.Color = vbRed ' 빨간색으로 설정
pos = InStr(pos +1, cell, strTest, 1) ' 대소문자 구분 안함.
Loop While ((pos > 0) And (strLen + pos - 1 <= cellLen))
end If
Next
End Sub