返回列表 上一主題 發帖

如何搜尋資料並將資料顯示為紅色字樣?

在這裡學到的
您參考一下下

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

TOP

        靜思自在 : 待人退一步,愛人寬一寸,就會活得很快樂。
返回列表 上一主題