如何使用 Excel 公式从格式化文本的 Excel 单元格中提取大文本?

How to extract big text from Excel cell in a formatted text with Excel formulas?

我在 Excel 单元格中有以下文字:

$abcd.$efghijk.$lmn.$op.$qrst.

我希望 Excel 单元格中的以上文本仅使用 Excel 公式:

abcd$abcd.efghijk$efghijk.lmn$lmn.op$op.qrst$qrst.

这是我根据讨论提出的建议。

在通用模块中,插入以下代码。

Public Function RepeatCustom(strInput As String) As String
Dim varInput As Variant
Dim i As Long
If Len(strInput) = 0 Then
    RepeatCustom = ""
Else
    varInput = Split(strInput, ".")
    For i = LBound(varInput) To UBound(varInput)
        RepeatCustom = RepeatCustom & " " & Mid(varInput(i), 2, Len(varInput(i))) & varInput(i)
    Next
    RepeatCustom = Replace(Trim(RepeatCustom), " ", ".") & "."
End If
End Function

然后假设包含原始数据的单元格是A2,你可以使用上面的UDF:

=重复自定义(A2)

请注意,代码是最小的,并且基于发布的示例。