deleting only arabic letters

osmanoca

Board Regular
Joined
Apr 16, 2016
Messages
87
hello dear mrexcel movers.
i have data with kurdish/Turkish and arabic words. so every cell has arabic and kurdish words together. i need to to delete all arabic letters . when i made with kutools it also delete some different letter like ç,ş,ö,î,ê,û.... because it thinks english alphabeth. how can delete only arabic letters.

example:
cümûdiyyeجمودیه
cünbân (F.) [ ]جنبان1
cünbişجنبش
cünd جند
cündî جندی
cünha جنحه
cünûd جنود


thanks for your help.


 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Are you OK with a user defined function, VBA?

Code:
Public Function TrimArabic(txt) As String
    Dim glyph As String
    Dim i As Long
    
    For i = 1 To Len(txt)
        glyph = Mid(txt, i, 1)
        If WorksheetFunction.Unicode(glyph) < &H600 Then
            TrimArabic = TrimArabic & glyph
        End If
    Next i
End Function
 
Upvote 0
A function is similar to a macro sub. A user defined function, a UDF, must go in a vba module, it will not work if it's entered in a Sheet's or Workbook's code. Once the function is entered in a module, you use it just as you would use any built-in Excel function: you enter the formula in a cell. If your mixed text is in cell A1, in B1 enter:

=TrimArabic(A1).

A UDF can be nested just like built-in functions. For instance, TrimArabic doesn't remove any trailing spaces left after cutting the Arabic characters. To remove those spaces, enter

=TRIM(TrimArabic(A1))

Hope this post helps you.
 
Upvote 0
i pasted that formula (=TrimArabic(A1). in B1 but after clicking enter it shows errror #AD ?

so i couldnt sorry. thanks for help but, if you can give macro will be better.
 
Upvote 0
OK. I used a worksheet function, =UNICODE(), in my VBA that was introduced with Excel 2013.

This version of the TrimArabic function does not use any workbook functions:
Code:
Public Function TrimArabic(txt) As String
''''
' Removes all characters U+0600 and higher from txt.
'
' Designed to remove Arabic characters, it also removes Chinese and
'   many, many other language group characters from txt.
''''
    Dim glyph As String
    Dim i As Long
    
    For i = 1 To Len(txt)
        glyph = Mid(txt, i, 1)
        If glyph < ChrW(&H600) Then
            TrimArabic = TrimArabic & glyph
        End If
    Next i
End Function

The workbook I used for testing can be downloaded from:
https://www.dropbox.com/s/j3ogjh9levm3z8a/trim_arabic_from_text_strings.xlsm?dl=0
 
Upvote 0
sorry i dont know to use it. i pasted as formula in Column B . but doesnt work. if you can explain me what i will do . how will use that code. it willl be better. or make it as macro. it is easier.. thanks for try.
 
Upvote 0
Ok. Here it is as a macro. It's designed to remove the characters from a user-selected range.

Code:
Option Explicit

Function TrimArabic(txt) As String
''''
' Removes all characters U+0600 and higher from txt.
'
' Designed to remove Arabic characters, it also removes Chinese and
'   many, many other language group characters from txt.
''''
    Dim glyph As String
    Dim i As Long
    
    For i = 1 To Len(txt)
        glyph = Mid(txt, i, 1)
        If glyph < ChrW(&H600) Then
            TrimArabic = TrimArabic & glyph
        End If
    Next i
End Function
''''

Sub RemoveArabic()
''''
' Removes all characters above U+05FF from a selected range.
'
' Requires TrimArabic().
''''
    Dim cell As Range

    If TypeName(Selection) <> "Range" Then Exit Sub

    For Each cell In Selection
        cell.Value = TrimArabic(cell.Value)
    Next cell
End Sub
''''
 
Upvote 0
I'm glad to read that the macro works for you. I appreciate getting a reply when something works correctly.
 
Upvote 0

Forum statistics

Threads
1,215,097
Messages
6,123,079
Members
449,094
Latest member
mystic19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top