+ Reply to Thread
Results 1 to 5 of 5

Ho to replace Name by ****

Hybrid View

  1. #1
    Registered User
    Join Date
    09-22-2017
    Location
    Hong Kong
    MS-Off Ver
    Office 10
    Posts
    21

    Ho to replace Name by ****

    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!

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Ho to replace Name by ****

    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. 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
    Attached Files Attached Files


    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

  3. #3
    Registered User
    Join Date
    09-22-2017
    Location
    Hong Kong
    MS-Off Ver
    Office 10
    Posts
    21

    Re: Ho to replace Name by ****

    Would you mind to explain the VBA a bit? I would like to learn the logic behind this if you don't mind...thanks!

  4. #4
    Registered User
    Join Date
    09-22-2017
    Location
    Hong Kong
    MS-Off Ver
    Office 10
    Posts
    21

    Re: Ho to replace Name by ****

    Thank you so much Sixthsense!

  5. #5
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Ho to replace Name by ****

    Another way...

    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
    Assuming your string is in A2, try the above UDF on the Sheet like this...
    =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.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. REPLACE function help replace two separate texts Ctrl H
    By Uldis in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-23-2015, 10:51 AM
  2. [SOLVED] find and replace to not replace characters found as wildcards
    By sabutler4 in forum Excel General
    Replies: 4
    Last Post: 07-03-2013, 06:48 PM
  3. Multiple Find and Replace to replace a list of strings
    By WalterP34 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-11-2011, 07:41 PM
  4. find and replace - replace data in rows to separated by commas
    By msdker in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-14-2006, 08:10 PM
  5. How can I use replace(alt+H) for mutiple items needing replace
    By Gary Brown in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-06-2005, 07:05 AM
  6. [SOLVED] How can I use replace(alt+H) for mutiple items needing replace
    By Gary Brown in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2005, 04:05 AM
  7. How can I use replace(alt+H) for mutiple items needing replace
    By Gery in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-15-2005, 01:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1