ไปยังเนื้อหาหลัก

วิธีการสะกดหรือแปลงตัวเลขเป็นคำภาษาอังกฤษใน Excel

สมมติว่าคุณมีตัวเลขราคาจำนวนมากและตอนนี้คุณต้องแปลงหรือสะกดให้เป็นสตริงข้อความ ตัวอย่างเช่นแปลง $123.55 เป็นคำภาษาอังกฤษ หนึ่งร้อยยี่สิบสามดอลลาร์และห้าสิบห้าเซนต์. ใน Excel ไม่มีสิ่งอำนวยความสะดวกที่มีประสิทธิภาพในการแก้ปัญหานี้ แต่ใช้รหัส VBA ที่ยาวและซับซ้อน ในบทความนี้ฉันจะแนะนำวิธีการจัดการกับมัน

สะกดหรือแปลงตัวเลขเป็นคำภาษาอังกฤษด้วยรหัส VBA

สะกดหรือแปลงตัวเลขเป็นคำภาษาอังกฤษด้วย Kutools for Excel


สะกดหรือแปลงตัวเลขเป็นคำภาษาอังกฤษด้วยรหัส VBA

รหัส VBA แบบยาวต่อไปนี้สามารถช่วยคุณในการสะกดตัวเลขลงในสตริงข้อความ ดำเนินการดังต่อไปนี้:

1. กด ALT + F11 และจะเปิดไฟล์ Microsoft Visual Basic สำหรับแอปพลิเคชัน หน้าต่าง

2. คลิก สิ่งที่ใส่เข้าไป > โมดูลและวางมาโครต่อไปนี้ในไฟล์ หน้าต่างโมดูล

VBA: สะกดตัวเลขสกุลเงินเป็นคำภาษาอังกฤษใน Excel

Function SpellNumberToEnglish(ByVal pNumber)
'Updateby20131113
Dim Dollars, Cents
arr = Array("", "", " Thousand ", " Million ", " Billion ", " Trillion ")
pNumber = Trim(Str(pNumber))
xDecimal = InStr(pNumber, ".")
If xDecimal > 0 Then
    Cents = GetTens(Left(Mid(pNumber, xDecimal + 1) & "00", 2))
    pNumber = Trim(Left(pNumber, xDecimal - 1))
End If
xIndex = 1
Do While pNumber <> ""
    xHundred = ""
    xValue = Right(pNumber, 3)
    If Val(xValue) <> 0 Then
        xValue = Right("000" & xValue, 3)
        If Mid(xValue, 1, 1) <> "0" Then
            xHundred = GetDigit(Mid(xValue, 1, 1)) & " Hundred "
        End If
        If Mid(xValue, 2, 1) <> "0" Then
            xHundred = xHundred & GetTens(Mid(xValue, 2))
        Else
            xHundred = xHundred & GetDigit(Mid(xValue, 3))
        End If
    End If
    If xHundred <> "" Then
        Dollars = xHundred & arr(xIndex) & Dollars
    End If
    If Len(pNumber) > 3 Then
        pNumber = Left(pNumber, Len(pNumber) - 3)
    Else
        pNumber = ""
    End If
    xIndex = xIndex + 1
Loop
Select Case Dollars
    Case ""
        Dollars = "No Dollars"
    Case "One"
        Dollars = "One Dollar"
    Case Else
        Dollars = Dollars & " Dollars"
End Select
Select Case Cents
    Case ""
        Cents = " and No Cents"
    Case "One"
        Cents = " and One Cent"
    Case Else
        Cents = " and " & Cents & " Cents"
End Select
SpellNumberToEnglish = Dollars & Cents
End Function
Function GetTens(pTens)
Dim Result As String
Result = ""
If Val(Left(pTens, 1)) = 1 Then
    Select Case Val(pTens)
        Case 10: Result = "Ten"
        Case 11: Result = "Eleven"
        Case 12: Result = "Twelve"
        Case 13: Result = "Thirteen"
        Case 14: Result = "Fourteen"
        Case 15: Result = "Fifteen"
        Case 16: Result = "Sixteen"
        Case 17: Result = "Seventeen"
        Case 18: Result = "Eighteen"
        Case 19: Result = "Nineteen"
        Case Else
    End Select
Else
Select Case Val(Left(pTens, 1))
    Case 2: Result = "Twenty "
    Case 3: Result = "Thirty "
    Case 4: Result = "Forty "
    Case 5: Result = "Fifty "
    Case 6: Result = "Sixty "
    Case 7: Result = "Seventy "
    Case 8: Result = "Eighty "
    Case 9: Result = "Ninety "
    Case Else
End Select
Result = Result & GetDigit(Right(pTens, 1))
End If
GetTens = Result
End Function
Function GetDigit(pDigit)
Select Case Val(pDigit)
    Case 1: GetDigit = "One"
    Case 2: GetDigit = "Two"
    Case 3: GetDigit = "Three"
    Case 4: GetDigit = "Four"
    Case 5: GetDigit = "Five"
    Case 6: GetDigit = "Six"
    Case 7: GetDigit = "Seven"
    Case 8: GetDigit = "Eight"
    Case 9: GetDigit = "Nine"
    Case Else: GetDigit = ""
End Select
End Function

3. จากนั้นบันทึกรหัสและกลับไปที่แผ่นงานในเซลล์ B2 ที่อยู่ติดกันให้ป้อนสูตร = SpellNumberToEnglish (A1)ดูภาพหน้าจอ:

4. จากนั้นกด เข้าสู่ และเลือกเซลล์ B2 จากนั้นลากจุดจับเติมไปยังช่วงที่มีสูตรนี้ตามที่คุณต้องการ และตัวเลขสกุลเงินทั้งหมดถูกสะกดเป็นคำภาษาอังกฤษ ดูภาพหน้าจอ:

หมายเหตุ: เนื่องจากเป็นสูตรเมื่อคุณต้องการคัดลอกและวางโปรดวางเป็นค่า


สะกดหรือแปลงตัวเลขเป็นคำภาษาอังกฤษด้วย Kutools for Excel

บางทีโค้ดยาว ๆ ข้างต้นอาจทำให้คุณเป็นบ้าได้โปรดอย่ากังวลที่นี่ฉันสามารถให้วิธีแก้ปัญหาที่ง่ายและรวดเร็ว กับ Kutools สำหรับ Excel's ตัวเลขเป็นคำ คุณสามารถแปลงตัวเลขเป็นสตริงข้อความได้อย่างรวดเร็วและสะดวก

Kutools สำหรับ Excel- รวมเครื่องมือที่มีประโยชน์มากกว่า 300 รายการสำหรับ Excel ทดลองใช้ฟรี 30 วันเต็มไม่ต้องใช้บัตรเครดิต! Get It Now

1. เลือกหมายเลขช่วงที่คุณต้องการสะกดแล้วคลิก Kutools > คอนเทนต์ > ตัวเลขเป็นคำ.
doc kutools จำนวนต่อคำ 1

2. ในกล่องโต้ตอบที่โผล่ขึ้นมาให้เลือก ภาษาอังกฤษ จาก ภาษา. และคุณสามารถดูผลลัพธ์จากด้านขวา ดูตัวอย่าง บานหน้าต่าง ดูภาพหน้าจอ:
doc kutools จำนวนต่อคำ 2

3. จากนั้นคลิก Ok or ใช้. และจำนวนราคาทั้งหมดได้ถูกแปลงเป็นสตริงข้อความในช่วงเดิม
doc kutools จำนวนต่อคำ 3

หมายเหตุ: หากคุณเพียงต้องการแปลงตัวเลขเป็นคำภาษาอังกฤษ (ไม่ใช่สกุลเงิน) โปรดตรวจสอบ ไม่ได้แปลงเป็นสกุลเงิน ช่องทำเครื่องหมาย
doc kutools จำนวนต่อคำ 3 doc kutools จำนวนต่อคำ 3

คุณสมบัติที่ยอดเยี่ยมของ ตัวเลขเป็นคำ สามารถแปลตัวเลขสกุลเงินเป็นข้อความของสกุลเงินเป็นภาษาอังกฤษหรือภาษาจีนได้อย่างง่ายดายเช่นแปล 32.01 เป็น "สามสิบสองดอลลาร์และหนึ่งเซ็นต์" หรือ "叁拾贰元零壹分" ทดลองใช้ฟรี!

การสาธิต: สะกดตัวเลขสกุลเงินเป็นคำภาษาอังกฤษ

สุดยอดเครื่องมือเพิ่มผลผลิตในสำนักงาน

🤖 Kutools AI ผู้ช่วย: ปฏิวัติการวิเคราะห์ข้อมูลโดยยึดตาม: การดำเนินการที่ชาญฉลาด   |  สร้างรหัส  |  สร้างสูตรที่กำหนดเอง  |  วิเคราะห์ข้อมูลและสร้างแผนภูมิ  |  เรียกใช้ฟังก์ชัน Kutools...
คุณสมบัติยอดนิยม: ค้นหา เน้น หรือระบุรายการที่ซ้ำกัน   |  ลบแถวว่าง   |  รวมคอลัมน์หรือเซลล์โดยไม่สูญเสียข้อมูล   |   รอบโดยไม่มีสูตร ...
การค้นหาขั้นสูง: VLookup หลายเกณฑ์    VLookup หลายค่า  |   VLookup ข้ามหลายแผ่น   |   การค้นหาที่ไม่ชัดเจน ....
รายการแบบเลื่อนลงขั้นสูง: สร้างรายการแบบหล่นลงอย่างรวดเร็ว   |  รายการแบบหล่นลงขึ้นอยู่กับ   |  เลือกหลายรายการแบบหล่นลง ....
ผู้จัดการคอลัมน์: เพิ่มจำนวนคอลัมน์เฉพาะ  |  ย้ายคอลัมน์  |  สลับสถานะการมองเห็นของคอลัมน์ที่ซ่อนอยู่  |  เปรียบเทียบช่วงและคอลัมน์ ...
คุณสมบัติเด่น: กริดโฟกัส   |  มุมมองการออกแบบ   |   บาร์สูตรใหญ่    สมุดงานและตัวจัดการชีต   |  ห้องสมุดทรัพยากร (ข้อความอัตโนมัติ)   |  เลือกวันที่   |  รวมแผ่นงาน   |  เข้ารหัส/ถอดรหัสเซลล์    ส่งอีเมลตามรายการ   |  ซุปเปอร์ฟิลเตอร์   |   ตัวกรองพิเศษ (กรองตัวหนา/ตัวเอียง/ขีดทับ...) ...
ชุดเครื่องมือ 15 อันดับแรก12 ข้อความ เครื่องมือ (เพิ่มข้อความ, ลบอักขระ, ... )   |   50 + แผนภูมิ ประเภท (แผนภูมิ Gantt, ... )   |   40+ ใช้งานได้จริง สูตร (คำนวณอายุตามวันเกิด, ... )   |   19 การแทรก เครื่องมือ (ใส่ QR Code, แทรกรูปภาพจากเส้นทาง, ... )   |   12 การแปลง เครื่องมือ (ตัวเลขเป็นคำ, การแปลงสกุลเงิน, ... )   |   7 ผสานและแยก เครื่องมือ (แถวรวมขั้นสูง, แยกเซลล์, ... )   |   ... และอื่น ๆ

เพิ่มพูนทักษะ Excel ของคุณด้วย Kutools สำหรับ Excel และสัมผัสประสิทธิภาพอย่างที่ไม่เคยมีมาก่อน Kutools สำหรับ Excel เสนอคุณสมบัติขั้นสูงมากกว่า 300 รายการเพื่อเพิ่มประสิทธิภาพและประหยัดเวลา  คลิกที่นี่เพื่อรับคุณสมบัติที่คุณต้องการมากที่สุด...

รายละเอียด


แท็บ Office นำอินเทอร์เฟซแบบแท็บมาที่ Office และทำให้งานของคุณง่ายขึ้นมาก

  • เปิดใช้งานการแก้ไขและอ่านแบบแท็บใน Word, Excel, PowerPoint, ผู้จัดพิมพ์, Access, Visio และโครงการ
  • เปิดและสร้างเอกสารหลายรายการในแท็บใหม่ของหน้าต่างเดียวกันแทนที่จะเป็นในหน้าต่างใหม่
  • เพิ่มประสิทธิภาพการทำงานของคุณ 50% และลดการคลิกเมาส์หลายร้อยครั้งให้คุณทุกวัน!
Comments (112)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hi! How would I go about adding hyphens ( - ) between compound numbers, so instead of it spelling 55 as Fifty Five it would spell Fifty-Five. Simply adding hyphens to all "tens" obviously doesn't work since that would mean tat 20,000,000 would be spelled as "Twenty- Million". Thanks to whoever can solve this!
This comment was minimized by the moderator on the site
Hi! How would I go about adding hyphens ( - ) between compound numbers, so instead of it spelling 55 as Fifty Five it would spell Fifty-Five. Simply adding hyphens to all "tens" obviously doesn't work since that would mean tat 20,000,000 would be spelled as "Twenty- Million". Thanks to whoever can solve this!
This comment was minimized by the moderator on the site
not suitable for indian currency allways show in doller
This comment was minimized by the moderator on the site
Hi prem,
At present, this Numbers to Words feature enables to convert numbers to Chinese Yuan and US Dollars.
This comment was minimized by the moderator on the site
How can i get actuall figure without "no cents/ no dollars", if it's not needed. Please Email me in shown Mail ID.
This comment was minimized by the moderator on the site
HAVE U GOT ANY SOLUTION FOR THIS
This comment was minimized by the moderator on the site
just delete the no cents on line 46 and no dollars on line 38, leave it "" only
This comment was minimized by the moderator on the site
I was unable to do it, I don't know what happened to it, first of all it was OK, but only for one time then it shows this sign #NAME? can any one help me in this regards.
This comment was minimized by the moderator on the site
Save it as Excel Macro Enable Workbook. and each time you will open the file, you'll see a Security Warning prompt (usually on top of Formula Bar) you have to click the Option button and tick the "Enable this content". This would solve your problem. Hope it would help
This comment was minimized by the moderator on the site
Please try one more time
This comment was minimized by the moderator on the site
everytime i close the file.. the complete program is lost.. how can i save this for all my excel files
This comment was minimized by the moderator on the site
thanks for the excellent job, I tried it , great , its working , greetings from Sri Lanka
This comment was minimized by the moderator on the site
We thank you for this guideline it is most helpful, but how can i change the currency from Dollars to Rwandan Francs?

Thanks
This comment was minimized by the moderator on the site
search the below texts in the vba code and replace eg : search 1 >> Search for "Dollars" Replace with "Rwandan Francs"
search 2 >> Search for "Dollar" Replace with "Rwandan Franc"
This comment was minimized by the moderator on the site
I have followed the guidelines and managed to do it perfectly well for the first time. I have been designing templates and it has worked for me. Thank you so much.
This comment was minimized by the moderator on the site
i wan to change this eg:( one hundred thousand rupees only ), pls explain me how to get that word "only"
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations