EXCEL中“张三”变红并加粗
1.按Alt+F11打开VBA编辑器
2.插入一模块,粘贴下面代码
3.修改代码里 strName = "张三" 换成你的人名
4.按F5运行
Sub MarkNameRedBold()
Dim cell As Range
Dim strName As String
strName = "张三" '改成你要查找的人名
For Each cell In ActiveSheet.UsedRange
If Not IsEmpty(cell.Value) Then
Dim pos As Integer
pos = InStr(1, cell.Value, strName, vbTextCompare)
Do While pos > 0
cell.Characters(Start:=pos, Length:=Len(strName)).Font.Bold = True
cell.Characters(Start:=pos, Length:=Len(strName)).Font.Color = RGB(255, 0, 0)
pos = InStr(pos + Len(strName), cell.Value, strName, vbTextCompare)
Loop
End If
Next cell
End Sub
浙公网安备 33010602011771号