Excel 如何因私人原因替换字符

Excel How to replace characters for private reason

例如单元格,

A1值是你好吗!

A2 值是你好早安

我想用一些公式来得到这样的结果。

结果:

H** a** y***

H**** G*** M******

你介意让我知道你对这个案子有什么建议吗? 谢谢。

想不出公式,但这个函数应该可以:

Public Function Masker(pString As String) As String
    
    Dim words As Variant
    Dim i As Long
    
    words = Split(pString, " ")
    For i = 0 To UBound(words, 1)
        words(i) = Left(words(i), 1) & String(Len(words(i)) - 1, "*")
    Next i
    
    Masker = Join(words, " ")
    
End Function