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
    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) = "ا"
                  Else
                     
                  End If
              Next
               End If
    changesearch = tempstr
    
    End Function
    any help 'd be highly appreciated

  2. #2
    Oh
    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
    Location
    Nanaimo, BC, Canada
    Posts
    2,090
    Articles
    79
    Blog Entries
    14
    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 (Excel)

    Master your data with Power Query: Purchase your copy of my book M is for Data Monkey today!

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/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
  •