• Sign Up
• Login
• API
• FAQ
• Tools
• Archive
daily pastebin goal
60%
SHARE
TWEET

# SpellNumber - Excel

a guest Jan 21st, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. Function SpellNumber(amt As Variant) As Variant
2. Dim FIGURE As Variant
3. Dim LENFIG As Integer
4. Dim i As Integer
5. Dim WORDs(19) As String
6. Dim tens(9) As String
7. WORDs(1) = "One"
8. WORDs(2) = "Two"
9. WORDs(3) = "Three"
10. WORDs(4) = "Four"
11. WORDs(5) = "Five"
12. WORDs(6) = "Six"
13. WORDs(7) = "Seven"
14. WORDs(8) = "Eight"
15. WORDs(9) = "Nine"
16. WORDs(10) = "Ten"
17. WORDs(11) = "Eleven"
18. WORDs(12) = "Twelve"
19. WORDs(13) = "Thirteen"
20. WORDs(14) = "Fourteen"
21. WORDs(15) = "Fifteen"
22. WORDs(16) = "Sixteen"
23. WORDs(17) = "Seventeen"
24. WORDs(18) = "Eighteen"
25. WORDs(19) = "Nineteen"
26. tens(2) = "Twenty"
27. tens(3) = "Thirty"
28. tens(4) = "Fourty"
29. tens(5) = "Fifty"
30. tens(6) = "Sixty"
31. tens(7) = "Seventy"
32. tens(8) = "Eighty"
33. tens(9) = "Ninety"
34. FIGURE = amt
35. FIGURE = Format(FIGURE, "FIXED")
36. FIGLEN = Len(FIGURE)
37. If FIGLEN < 12 Then
38. FIGURE = Space(12 - FIGLEN) & FIGURE
39. End If
40.
41. For i = 1 To 3
42. If Val(Left(FIGURE, 2)) < 20 And Val(Left(FIGURE, 2)) > 0 Then
43. SpellNumber = SpellNumber & WORDs(Val(Left(FIGURE, 2)))
44. ElseIf Val(Left(FIGURE, 2)) > 19 Then
45. SpellNumber = SpellNumber & tens(Val(Left(FIGURE, 1)))
46. SpellNumber = SpellNumber & WORDs(Val(Right(Left(FIGURE, 2), 1)))
47. End If
48. If i = 1 And Val(Left(FIGURE, 2)) > 0 Then
49. SpellNumber = SpellNumber & " Crore "
50. ElseIf i = 2 And Val(Left(FIGURE, 2)) > 0 Then
51. SpellNumber = SpellNumber & " Lakh "
52. ElseIf i = 3 And Val(Left(FIGURE, 2)) > 0 Then
53. SpellNumber = SpellNumber & " Thousand "
54. End If
55. FIGURE = Mid(FIGURE, 3)
56. Next i
57. If Val(Left(FIGURE, 1)) > 0 Then
58. SpellNumber = SpellNumber & WORDs(Val(Left(FIGURE, 1))) + " Hundred "
59. End If
60. FIGURE = Mid(FIGURE, 2)
61. If Val(Left(FIGURE, 2)) < 20 And Val(Left(FIGURE, 2)) > 0 Then
62. SpellNumber = SpellNumber & WORDs(Val(Left(FIGURE, 2)))
63. ElseIf Val(Left(FIGURE, 2)) > 19 Then
64. SpellNumber = SpellNumber & tens(Val(Left(FIGURE, 1)))
65. SpellNumber = SpellNumber & WORDs(Val(Right(Left(FIGURE, 2), 1)))
66. End If
67. FIGURE = Mid(FIGURE, 4)
68. If Val(FIGURE) > 0 Then
69. SpellNumber = SpellNumber & " Paise "
70. If Val(Left(FIGURE, 2)) < 20 And Val(Left(FIGURE, 2)) > 0 Then
71. SpellNumber = SpellNumber & WORDs(Val(Left(FIGURE, 2)))
72. ElseIf Val(Left(FIGURE, 2)) > 19 Then
73. SpellNumber = SpellNumber & tens(Val(Left(FIGURE, 1)))
74. SpellNumber = SpellNumber & WORDs(Val(Right(Left(FIGURE, 2), 1)))
75. End If
76. End If
77. FIGURE = amt
78. FIGURE = Format(FIGURE, "FIXED")
79. If Val(FIGURE) > 0 Then
80. SpellNumber = SpellNumber & " Taka Only "
81. End If
82. End Function
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top