I would like to replace part of the name by ***
For example,
Justin Backham -> J***** B******
Kim Jong Un -> K** J*** U*
but I have no idea how to do this with a formula...could you guys give me a hand pls....
Thank you all!
I would like to replace part of the name by ***
For example,
Justin Backham -> J***** B******
Kim Jong Un -> K** J*** U*
but I have no idea how to do this with a formula...could you guys give me a hand pls....
Thank you all!
How to install your new code
- Copy the Excel VBA code
- Select the workbook in which you want to store the Excel VBA code
- Press Alt+F11 to open the Visual Basic Editor
- Choose Insert > Module
- Edit > Paste the macro into the module that appeared
- Close the VBEditor
- Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)
Function DataMask(v As Variant) As String Dim sResult As String, sVal As String, blCheck As Boolean sVal = v sVal = " " & sVal For i = 1 To Len(sVal) If Not blCheck Then If Mid(sVal, i, 1) = " " Then sResult = sResult & " " & Mid(sVal, i + 1, 1) blCheck = True Else sResult = sResult & "*" End If Else blCheck = False End If Next i DataMask = Trim(sResult) End Function
If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
Mark your thread as Solved
If the suggestion helps you, then Click *below to Add Reputation
Would you mind to explain the VBA a bit? I would like to learn the logic behind this if you don't mind...thanks!
Thank you so much Sixthsense!
Another way...
Assuming your string is in A2, try the above UDF on the Sheet like this...Function StringMask(ByVal str As String) As String Dim Arr() As String Dim i As Long Arr = Split(str, " ") For i = 0 To UBound(Arr) Arr(i) = Left(Arr(i), 1) & WorksheetFunction.Rept("*", Len(Arr(i)) - 1) Next i StringMask = Join(Arr, " ") End Function
=StringMask(A2)
Regards
sktneer
Treat people the way you want to be treated. Talk to people the way you want to be talked to.
Respect is earned NOT given.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks