Results 1 to 3 of 3

Thread: Help with code to find and replace

  1. #1

    Question Help with code to find and replace

    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hi All
    I'm new here and I hope you help me
    I have a code to find a certain letter in Arabic and replace it with another letter
    my code finds every letter ( أ , إ , آ ) and replace it with ( ا )
    the problem is that the code replaces every letter in the text and what I need is to replace
    the first letter only if it 's one of those assigned letters
    Here's my code
    Public Function changesearch(Mytxt) As String
    Dim tempstr As String
    tempstr = Trim(Mytxt)
         If tempstr Like "*[أاآإ]*" Then
             For b = 1 To Len(tempstr)
                  If Mid(tempstr, b, 1) = "ا" Or Mid(tempstr, b, 1) = "إ" Or Mid(tempstr, b, 1) = "أ" Or Mid(tempstr, b, 1) = "آ" Then
                   Mid(tempstr, b, 1) = "ا"
                  End If
               End If
    changesearch = tempstr
    End Function
    any help 'd be highly appreciated

  2. #2
    Finally I got it
    Change the
    Mid(tempstr,b,1) to Mid(tempstr,1,1)
    It works as I hoped
    anyway thanks

  3. #3
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Nanaimo, BC, Canada
    Blog Entries
    Excel Version
    Excel Office 365 Insider
    Hi Aysam,

    Welcome to the forum, and thanks for posting that you found a solution. Hopefully next time we can be a bit more help to you.
    Ken Puls, FCPA, FCMA, MS MVP

    Learn to Master Your Data at the Power Query Academy (the world's most comprehensive online Power Query training), with my book M is for Data Monkey, or our new Power Query Recipe cards!

    Main Site: -||- Blog: -||- Forums:
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

Posting Permissions

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