效果如下:
Public Sub 加下划线()
Cells(7, 1) = Cells(5, 12) + Cells(6, 12) + Cells(7, 12)
Dim St$, i&, j&
St = [A7]
i = InStr(St, "我单位已完成了")
j = InStr(St, "□单元工程")
With [A7].Characters(Start:=i + 7, Length:=j - i - 7).Font
.Underline = xlUnderlineStyleSingle
End With
End Sub
Public Sub R替换()
Dim St$, i&, j&
Dim myRange As Range
Dim myChr As Characters
Set myRange = Range("A7")
St = [A7]
i = InStr(St, "R")
With myRange
Set myChr = .Characters(Start:=i, Length:=1)
With myChr.Font
.Name = "Wingdings 2"
.Size = 15
.Bold = True
.Italic = False
.ColorIndex = 1
End With
End With
Set myChr = Nothing
Set myRange = Nothing
End Sub
Public Sub 加下划线2()
Call 加下划线
Call R替换
End Sub