如何在Excel中將數字轉換為印度盧比的單詞?
本文,我將介紹如何在Excel中將數字列表轉換為印度盧比或英語的單詞。
使用VBA代碼將數字轉換為印度盧比的單詞
以下VBA代碼可以幫助您將數字轉換為盧比的單詞,請按以下步驟操作:
1。 按住 ALT + F11 鍵打開 Microsoft Visual Basic for Applications 窗口。
2。 點擊 插入 > 模塊,然後將以下代碼粘貼到“模塊窗口”中。
VBA代碼:將數字轉換為盧比的單詞
Public Function RupeeFormat(SNum As String)
'Updateby Extendoffice
Dim xDPInt As Integer
Dim xArrPlace As Variant
Dim xRStr_Paisas As String
Dim xNumStr As String
Dim xF As Integer
Dim xTemp As String
Dim xStrTemp As String
Dim xRStr As String
Dim xLp As Integer
xArrPlace = Array("", "", " Thousand ", " Lacs ", " Crores ", " Trillion ", "", "", "", "")
On Error Resume Next
If SNum = "" Then
RupeeFormat = ""
Exit Function
End If
xNumStr = Trim(str(SNum))
If xNumStr = "" Then
RupeeFormat = ""
Exit Function
End If
xRStr = ""
xLp = 0
If (xNumStr > 999999999.99) Then
RupeeFormat = "Digit excced Maximum limit"
Exit Function
End If
xDPInt = InStr(xNumStr, ".")
If xDPInt > 0 Then
If (Len(xNumStr) - xDPInt) = 1 Then
xRStr_Paisas = RupeeFormat_GetT(Left(Mid(xNumStr, xDPInt + 1) & "0", 2))
ElseIf (Len(xNumStr) - xDPInt) > 1 Then
xRStr_Paisas = RupeeFormat_GetT(Left(Mid(xNumStr, xDPInt + 1), 2))
End If
xNumStr = Trim(Left(xNumStr, xDPInt - 1))
End If
xF = 1
Do While xNumStr <> ""
If (xF >= 2) Then
xTemp = Right(xNumStr, 2)
Else
If (Len(xNumStr) = 2) Then
xTemp = Right(xNumStr, 2)
ElseIf (Len(xNumStr) = 1) Then
xTemp = Right(xNumStr, 1)
Else
xTemp = Right(xNumStr, 3)
End If
End If
xStrTemp = ""
If Val(xTemp) > 99 Then
xStrTemp = RupeeFormat_GetH(Right(xTemp, 3), xLp)
If Right(Trim(xStrTemp), 3) <> "Lac" Then
xLp = xLp + 1
End If
ElseIf Val(xTemp) <= 99 And Val(xTemp) > 9 Then
xStrTemp = RupeeFormat_GetT(Right(xTemp, 2))
ElseIf Val(xTemp) < 10 Then
xStrTemp = RupeeFormat_GetD(Right(xTemp, 2))
End If
If xStrTemp <> "" Then
xRStr = xStrTemp & xArrPlace(xF) & xRStr
End If
If xF = 2 Then
If Len(xNumStr) = 1 Then
xNumStr = ""
Else
xNumStr = Left(xNumStr, Len(xNumStr) - 2)
End If
ElseIf xF = 3 Then
If Len(xNumStr) >= 3 Then
xNumStr = Left(xNumStr, Len(xNumStr) - 2)
Else
xNumStr = ""
End If
ElseIf xF = 4 Then
xNumStr = ""
Else
If Len(xNumStr) <= 2 Then
xNumStr = ""
Else
xNumStr = Left(xNumStr, Len(xNumStr) - 3)
End If
End If
xF = xF + 1
Loop
If xRStr = "" Then
xRStr = "No Rupees"
Else
xRStr = " Rupees " & xRStr
End If
If xRStr_Paisas <> "" Then
xRStr_Paisas = " and " & xRStr_Paisas & " Paisas"
End If
RupeeFormat = xRStr & xRStr_Paisas & " Only"
End Function
Function RupeeFormat_GetH(xStrH As String, xLp As Integer)
Dim xRStr As String
If Val(xStrH) < 1 Then
RupeeFormat_GetH = ""
Exit Function
Else
xStrH = Right("000" & xStrH, 3)
If Mid(xStrH, 1, 1) <> "0" Then
If (xLp > 0) Then
xRStr = RupeeFormat_GetD(Mid(xStrH, 1, 1)) & " Lac "
Else
xRStr = RupeeFormat_GetD(Mid(xStrH, 1, 1)) & " Hundred "
End If
End If
If Mid(xStrH, 2, 1) <> "0" Then
xRStr = xRStr & RupeeFormat_GetT(Mid(xStrH, 2))
Else
xRStr = xRStr & RupeeFormat_GetD(Mid(xStrH, 3))
End If
End If
RupeeFormat_GetH = xRStr
End Function
Function RupeeFormat_GetT(xTStr As String)
Dim xTArr1 As Variant
Dim xTArr2 As Variant
Dim xRStr As String
xTArr1 = Array("Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen")
xTArr2 = Array("", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety")
Result = ""
If Val(Left(xTStr, 1)) = 1 Then
xRStr = xTArr1(Val(Mid(xTStr, 2, 1)))
Else
If Val(Left(xTStr, 1)) > 0 Then
xRStr = xTArr2(Val(Left(xTStr, 1)) - 1)
End If
xRStr = xRStr & RupeeFormat_GetD(Right(xTStr, 1))
End If
RupeeFormat_GetT = xRStr
End Function
Function RupeeFormat_GetD(xDStr As String)
Dim xArr_1() As Variant
xArr_1 = Array(" One", " Two", " Three", " Four", " Five", " Six", " Seven", " Eight", " Nine", "")
If Val(xDStr) > 0 Then
RupeeFormat_GetD = xArr_1(Val(xDStr) - 1)
Else
RupeeFormat_GetD = ""
End If
End Function
3。 插入代碼後,保存並關閉代碼窗口,返回到工作表,然後輸入以下公式: = RupeeFormat(A2) 到一個空白單元格中,然後向下拖動填充手柄以將此公式應用於其他單元格,所有數字均以盧比表示,請參見屏幕截圖:
具有驚人功能的將數字轉換為英文單詞
如果您想將數字轉換成英文單詞, Excel的Kutools“ 數字到單詞 功能可以幫助您快速輕鬆地解決此工作。
提示:要應用此 字數 功能,首先,您應該下載 Excel的Kutools,然後快速輕鬆地應用該功能。
安裝後 Excel的Kutools,請這樣做:
1。 選擇要轉換的數字列表,然後單擊 庫工具 > 內容 > 數字到單詞,請參見屏幕截圖:
2。 在 數字到貨幣單詞 對話框中選擇 English 選項從 語言 部分,然後單擊 Ok 按鈕,所選內容中的數字已轉換為英語貨幣單詞,請參見屏幕截圖:
- 超級公式欄 (輕鬆編輯多行文本和公式); 閱讀版式 (輕鬆讀取和編輯大量單元格); 粘貼到過濾範圍...
- 合併單元格/行/列 和保存數據; 拆分單元格內容; 合併重複的行和總和/平均值...防止細胞重複; 比較範圍...
- 選擇重複或唯一 行; 選擇空白行 (所有單元格都是空的); 超級查找和模糊查找 在許多工作簿中; 隨機選擇...
- 確切的副本 多個單元格,無需更改公式參考; 自動創建參考 到多張紙; 插入項目符號,複選框等...
- 收藏并快速插入公式,範圍,圖表和圖片; 加密單元 帶密碼 創建郵件列表 並發送電子郵件...
- 提取文字,添加文本,按位置刪除, 刪除空間; 創建和打印分頁小計; 在單元格內容和註釋之間轉換...
- 超級濾鏡 (將過濾方案保存並應用於其他工作表); 高級排序 按月/週/日,頻率及更多; 特殊過濾器 用粗體,斜體...
- 結合工作簿和工作表; 根據關鍵列合併表; 將數據分割成多個工作表; 批量轉換xls,xlsx和PDF...
- 數據透視表分組依據 週號,週幾等 顯示未鎖定的單元格 用不同的顏色 突出顯示具有公式/名稱的單元格...
- 在Word,Excel,PowerPoint中啟用選項卡式編輯和閱讀,發布者,Access,Visio和Project。
- 在同一窗口的新選項卡中而不是在新窗口中打開並創建多個文檔。
- 將您的工作效率提高 50%,每天為您減少數百次鼠標點擊!
Sort comments by
#44622
This comment was minimized by the moderator on the site
0
0
#44529
This comment was minimized by the moderator on the site
0
0
#44441
This comment was minimized by the moderator on the site
0
0
#44330
This comment was minimized by the moderator on the site
0
0
#43566
This comment was minimized by the moderator on the site
0
0
#43299
This comment was minimized by the moderator on the site
Report
0
0
#42726
This comment was minimized by the moderator on the site
0
0
#42545
This comment was minimized by the moderator on the site
0
0
#42292
This comment was minimized by the moderator on the site
0
0
#42365
This comment was minimized by the moderator on the site
Report
0
0
#42165
This comment was minimized by the moderator on the site
0
0
There are no comments posted here yet