Sub AAA() Dim R As Range, L As Long, S As String Application.ScreenUpdating = False S = "紅" "要標記的字元 L = Len(S) For Each R In Selection If InStr(R, S) > 0 Then R.Characters(InStr(R, S), L).Font.Color = vbRed Next Application.ScreenUpdating = TrueEnd Sub
Sub AAA() Dim R As Range, L As Long, S As String Application.ScreenUpdating = False S = "紅" "要標記的字元 L = Len(S) For Each R In Selection If InStr(R, S) > 0 Then R.Characters(InStr(R, S), L).Font.Color = vbRed Next Application.ScreenUpdating = TrueEnd Sub
開啟表格,按ALT+F11開啟VB編輯器後,按F7在出來的視窗把程式碼複製進去,修改好程式碼中你需要標紅的字元,後回到表格,選中需要標紅的區域,儘量不要選太多不相關的區域,那樣會導致速度很慢。選好區域後按ALT+F8 選擇對應的宏執行。樓上那個程式碼雖然可以實現,但是字元多的話速度肯定是非常慢的。而且只能一個字元
Sub AAA() Dim R As Range, L As Long, S As String Application.ScreenUpdating = False S = "紅" "要標記的字元 L = Len(S) For Each R In Selection If InStr(R, S) > 0 Then R.Characters(InStr(R, S), L).Font.Color = vbRed Next Application.ScreenUpdating = TrueEnd Sub
Sub AAA() Dim R As Range, L As Long, S As String Application.ScreenUpdating = False S = "紅" "要標記的字元 L = Len(S) For Each R In Selection If InStr(R, S) > 0 Then R.Characters(InStr(R, S), L).Font.Color = vbRed Next Application.ScreenUpdating = TrueEnd Sub