+ Reply to Thread
Results 1 to 2 of 2

Spell Numbers to arabic Words

  1. #1
    Registered User
    Join Date
    02-17-2014
    Location
    Cairo,Egypt
    MS-Off Ver
    Excel 2010
    Posts
    1

    Spell Numbers to arabic Words

    I am using the following VBA to spell numbers in arabic words !
    however , the solution resulted to having the numbers spelled to ASCII codes .. Can anyone help?
    Public Function SFormatNumber(ByVal x As Double) As String
    Dim Letter1, Letter2, Letter3, Letter4, Letter5, Letter6 As String
    Dim C As String
    C = Format(Int(x), "000000000000")
    Dim C1 As Double
    C1 = Val(Mid(C, 12, 1))
    Select Case C1
    Case Is = 1: Letter1 = "واحد"
    Case Is = 2: Letter1 = "اثنان"
    Case Is = 3: Letter1 = "ثلاثة"
    Case Is = 4: Letter1 = "اربعة"
    Case Is = 5: Letter1 = "خمسة"
    Case Is = 6: Letter1 = "ستة"
    Case Is = 7: Letter1 = "سبعة"
    Case Is = 8: Letter1 = "ثمانية"
    Case Is = 9: Letter1 = "تسعة"
    End Select


    Dim C2 As Double
    C2 = Val(Mid(C, 11, 1))
    Select Case C2
    Case Is = 1: Letter2 = "عشر"
    Case Is = 2: Letter2 = "عشرون"
    Case Is = 3: Letter2 = "ثلاثون"
    Case Is = 4: Letter2 = "اربعون"
    Case Is = 5: Letter2 = "خمسون"
    Case Is = 6: Letter2 = "ستون"
    Case Is = 7: Letter2 = "سبعون"
    Case Is = 8: Letter2 = "ثمانون"
    Case Is = 9: Letter2 = "تسعون"
    End Select


    If Letter1 <> "" And C2 > 1 Then Letter2 = Letter1 + " و" + Letter2
    If Letter2 = "" Then
    Letter2 = Letter1
    End If
    If C1 = 0 And C2 = 1 Then Letter2 = Letter2 + "ة"
    If C1 = 1 And C2 = 1 Then Letter2 = "احدى عشر"
    If C1 = 2 And C2 = 1 Then Letter2 = "اثنى عشر"
    If C1 > 2 And C2 = 1 Then Letter2 = Letter1 + " " + Letter2
    Dim C3 As Double
    C3 = Val(Mid(C, 10, 1))
    Select Case C3
    Case Is = 1: Letter3 = "مائة"
    Case Is = 2: Letter3 = "مئتان"
    Case Is > 2: Letter3 = Left(SFormatNumber(C3), Len(SFormatNumber(C3)) - 1) + "مائة"
    End Select
    If Letter3 <> "" And Letter2 <> "" Then Letter3 = Letter3 + " و" + Letter2
    If Letter3 = "" Then Letter3 = Letter2


    Dim C4 As Double
    C4 = Val(Mid(C, 7, 3))
    Select Case C4
    Case Is = 1: Letter4 = "الف"
    Case Is = 2: Letter4 = "الفان"
    Case 3 To 10: Letter4 = SFormatNumber(C4) + " الاف"
    Case Is > 10: Letter4 = SFormatNumber(C4) + " الف"
    End Select
    If Letter4 <> "" And Letter3 <> "" Then Letter4 = Letter4 + " و" + Letter3
    If Letter4 = "" Then Letter4 = Letter3
    Dim C5 As Double
    C5 = Val(Mid(C, 4, 3))
    Select Case C5
    Case Is = 1: Letter5 = "مليون"
    Case Is = 2: Letter5 = "مليونان"
    Case 3 To 10: Letter5 = SFormatNumber(C5) + " ملايين"
    Case Is > 10: Letter5 = SFormatNumber(C5) + " مليون"
    End Select
    If Letter5 <> "" And Letter4 <> "" Then Letter5 = Letter5 + " و" + Letter4
    If Letter5 = "" Then Letter5 = Letter4


    Dim C6 As Double
    C6 = Val(Mid(C, 1, 3))
    Select Case C6
    Case Is = 1: Letter6 = "مليار"
    Case Is = 2: Letter6 = "ملياران"
    Case Is > 2: Letter6 = SFormatNumber(C6) + " مليار"
    End Select
    If Letter6 <> "" And Letter5 <> "" Then Letter6 = Letter6 + " و" + Letter5
    If Letter6 = "" Then Letter6 = Letter5
    SFormatNumber = Letter6


    End Function

  2. #2
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Spell Numbers to arabic Words

    Welcome to the forum.

    We'd like to help you but first..

    Pls take some minutes to read forum rules and specially-in this case- rule#3 and add code tags around your code.
    Then anyone will be able to help you.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

+ 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. [SOLVED] Spell number in Arabic
    By noman999 in forum Excel Programming / VBA / Macros
    Replies: 31
    Last Post: 02-21-2021, 02:31 AM
  2. spell the numbers in words
    By israrkhan in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-13-2014, 10:46 AM
  3. spellnumber formula for arabic amount in words by typing digits
    By mehmoud hussain in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-10-2014, 08:22 AM
  4. How does Excel spell out numbers in words ?
    By Kat in forum Excel General
    Replies: 1
    Last Post: 06-20-2006, 09:35 PM
  5. How do I spell numbers as words for writing checks in Excel?
    By Heather in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-11-2005, 05:06 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