Hi
Here is an alternative. It’s based on Hans coding, that is to say the way he did to separate the English and Arab words.
Code: Select all
Option Explicit' https://eileenslounge.com/viewtopic.php?f=30&t=39197
Sub TestitPretty()
Dim Ay() As String: ReDim Ay(1 To 6)
Let Ay(1) = "Ahmed": Ay(2) = ChrW(1537): Ay(3) = "Yasser": Ay(4) = ChrW(1538): Ay(5) = "Satan": Ay(6) = "Hans"
Dim strEng As String, strArb As String, Cnt As Long
For Cnt = 1 To UBound(Ay())
If AscW(Ay(Cnt)) >= &H600 Then
Let strArb = strArb & Cnt & " "
Else
Let strEng = strEng & Cnt & " "
End If
Next Cnt
Dim BeaV() As Variant, DieV() As Variant '
Let BeaV() = Application.Index(Ay(), 1, Split(Left(strArb, Len(strArb) - 1))): DieV() = Application.Index(Ay(), 1, Split(StrReverse(Left(strEng, Len(strEng) - 1))))
End Sub
Sub Testit()
Dim Ay() As String: ReDim Ay(1 To 6)
Let Ay(1) = "Ahmed"
Let Ay(2) = ChrW(1537) ' "????"
Let Ay(3) = "Yasser"
Let Ay(4) = ChrW(1538) ' "????"
Let Ay(5) = "Satan"
Let Ay(6) = "Hans"
Dim strEng As String, strArb As String
Dim Cnt As Long
For Cnt = 1 To UBound(Ay())
If AscW(Ay(Cnt)) >= &H600 Then
Let strArb = strArb & Cnt & " "
Else
Let strEng = strEng & Cnt & " "
End If
Next Cnt
Let strArb = Left(strArb, Len(strArb) - 1): strEng = Left(strEng, Len(strEng) - 1) ' Take last space off
Let strEng = StrReverse(strEng)
Dim Bea() As String, Die() As String ' Split returns elements of string type
Let Bea() = Split(strArb, " ", -1, vbBinaryCompare): Die() = Split(strEng, " ", -1, vbBinaryCompare)
Dim BeaV() As Variant, DieV() As Variant ' App Index returns Elements of variant type
Let BeaV() = Application.Index(Ay(), 1, Bea()): DieV() = Application.Index(Ay(), 1, Die())
MsgBox Prompt:="In BeaV() is " & Join(BeaV(), " ") & vbCr & vbLf & "In DeaV() is " & Join(DieV(), " ")
End Sub
Alan.