Sub 改變字串顏色()
Dim A As Range
Dim cclor As Integer
Dim cput As String
cclor = InputBox("顏色代碼: 1黑 2白 3紅 4綠 5藍 6黃 7紫 ", "請選擇顏色:1-7")
cput = InputBox("請輸入要改變顏色的字串:", "請輸入字串 ")
For Each A In Cells.SpecialCells(xlCellTypeConstants)
A.Font.ColorIndex = -4105 '自動字型顏色
If InStr(A, cput) > 0 Then
For i = 1 To Len(A)
If Mid(A, i, Len(cput)) = cput Then
A.Characters(i, Len(cput)).Font.ColorIndex = cclor
i = i + Len(cput) - 1
End If
Next
End If
Next
End Sub作者: handmuch 時間: 2011-10-4 16:17