This looks right.
Option Explicit
Function udf_Color_Piece(rTXT As Range, Optional iNDX As Long = 1)
Dim c As Long, seg As Long, clr As Long
seg = 0
clr = -9
udf_Color_Piece = vbNullString
For c = 1 To Len(rTXT.Text)
With rTXT.Characters(Start:=c, Length:=1)
If clr <> .Font.Color Then
seg = seg + 1
clr = .Font.Color
If seg > iNDX Then Exit Function
End If
If seg = iNDX Then
udf_Color_Piece = udf_Color_Piece & .Text
End If
End With
Next c
End Function
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…