Monday, December 17, 2012

How to convert a numeric value into English words in excel

1.Open the excel file in which you want to use this option
2. Press Alt+F11 goto insert menu then module then copy the below code and paste.

3. Press Alt+Q to Save code and return on Excel sheet



Function Sekr(fig, Optional point = "Point") As String
Dim digit(14) As Integer
alpha = Array("", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety")
figi = Trim(StrReverse(Str(Int(Abs(fig)))))
For i = 1 To Len(figi)
digit(i) = Mid(figi, i, 1)
Next
For i = 2 To Len(figi) Step 3
If digit(i) = 1 Then
digit(i) = digit(i - 1) + 10: digit(i - 1) = 0
Else: If digit(i) > 1 Then digit(i) = digit(i) + 18
End If
Next
For i = 1 To Len(figi)
If (i Mod 3) = 0 And digit(i) > 0 Then Sekr = "hundred " & Sekr
If (i Mod 3) = 1 And digit(i) + digit(i + 1) + digit(i + 2) > 0 Then _
Sekr = Choose(i / 3, "thousand ", "million ", "billion ") & Sekr
Sekr = Trim(alpha(digit(i)) & " " & Sekr)
Next
If fig <> Int(fig) Then
figc = StrReverse(figi)
If figc = 0 Then figc = ""
figd = Trim(WorksheetFunction.Substitute(Str(Abs(fig)), figc & ".", ""))
Sekr = Trim(Sekr & " " & point)
For i = 1 To Len(figd)
If Val(Mid(figd, i, 1)) > 0 Then
Sekr = Sekr & " " & alpha(Mid(figd, i, 1))
Else: Sekr = Sekr & " Zero"
End If
Next
End If
If fig < 0 Then Sekr = "Negative " & Sekr
End Function


4. Now to use this function use =Sekr(cell details)


Top 10 Craziest Motorcycles of the world 

No comments:

Post a Comment

Blogger Tips And Tricks|Latest Tips For Bloggers Free Backlinks