提取粗体字,有什么解决办法吗?

Eli*_*ior 10 microsoft-excel

我打算只提取粗体字作为一列。有没有人有 VBA 代码来识别粗体文本?我需要他识别粗体的帖子并只提取突出显示的单词 在此处输入图片说明

har*_*ymc 20

堆栈溢出后 Excel 在文本提取粗体字包含以下 VBA 函数来逐个字符地提取粗体文本:

 Public Function findAllBold(ByVal rngText As Range) As String
    Dim theCell As Range
    Set theCell = rngText.Cells(1, 1)

    For i = 1 To Len(theCell.Value)       
        If theCell.Characters(i, 1).Font.Bold = True Then          
            If theCell.Characters(i + 1, 1).Text = " " Then
                theChar = theCell.Characters(i, 1).Text & ", "
                Else
                theChar = theCell.Characters(i, 1).Text
            End If
            Results = Results & theChar
        End If
   Next i
   findAllBold = Results
End Function
Run Code Online (Sandbox Code Playgroud)

此函数在找到的单词之间添加逗号。要省略这一点,请删除此文本:& ", "if在这种情况下,整个命令可以缩短为一行:
theChar = theCell.Characters(i, 1).Text.

使用此函数从第一个单元格中提取粗体文本,然后将公式扩展到以下行:

在此处输入图片说明