- 帖子
- 57
- 主題
- 25
- 精華
- 0
- 積分
- 87
- 點名
- 0
- 作業系統
- xp2
- 軟體版本
- office2003
- 閱讀權限
- 20
- 性別
- 男
- 註冊時間
- 2010-9-16
- 最後登錄
- 2023-11-29
|
3#
發表於 2011-10-4 10:15
| 只看該作者
在這裡學到的
您參考一下下
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 |
|