使用步骤:
选中你想要处理的单元格或单元格范围。
按 Alt + F8 打开宏对话框,选择 ReplaceCommaWithCommaAndNewLineAndBoldColonText 宏并运行。
效果示例如下图

js
Sub ReplaceCommaWithCommaAndNewLineAndBoldColonText()
Dim cell As Range
Dim selectedRange As Range
Dim newText As String
Dim colonPos As Integer
Dim ws As Worksheet
' 获取选中的范围
Set selectedRange = Application.Selection
' 获取当前工作表
Set ws = ActiveSheet
' 检查是否有选中的单元格
If Not selectedRange Is Nothing Then
' 遍历每个选中的单元格
For Each cell In selectedRange
If Not IsEmpty(cell.Value) Then
' 替换"、"为"、" + CHAR(10)
newText = Replace(cell.Value, ":", ":" & vbLf)
' 更新单元格内容
cell.Value = newText
' 设置单元格自动换行
cell.WrapText = True
' 查找":"的位置
colonPos = InStr(cell.Value, ":")
' 如果找到":",则将":"前面的文字加粗
If colonPos > 0 Then
' 设置范围
ws.Range(cell.Address).Characters(Start:=1, Length:=colonPos - 1).Font.Bold = True
End If
End If
Next cell
Else
MsgBox "请先选中一些单元格。", vbExclamation
End If
End Sub