excel怎么把数字变成大写
在Excel中,有多种方法可以将数字转换成大写。小编将介绍使用设置单元格格式、使用公式以及使用VBA宏三种方法来实现这一功能。
一、设置单元格格式
1. 复制金额列的数据到大写金额列,选中单元格,右键打开快捷菜单,选择【设置单元格格式】。
2. 在弹出的窗口中,选择【数字】-【特殊】,在下拉列表中选择【中文大写】。
3. 确定并应用该格式到选中的单元格,即可将数字转换成大写。
二、使用公式
1. 在需要转换的单元格中输入以下公式:
=SUBSTITUTE(SUBSTITUTE(IF(A1 0 Then
NumberDecimal = GetTens(Left(Mid(MyNumber, DecimalPlace + 1) & "00", 2))
MyNumber = Trim(Left(MyNumber, DecimalPlace 1))
End If
Count = 1
Do While MyNumber ""
ReDim Preserve Part(Count)
If Len(MyNumber) > 3 Then
Part(Count) = GetHundreds(Right(MyNumber, 3))
MyNumber = Left(MyNumber, Len(MyNumber) 3)
Else
Part(Count) = GetHundreds(MyNumber)
MyNumber = ""
End If
Count = Count + 1
Loop
For Count = UBound(Part) To 1 Step -1
If Part(Count) "" Then
If StringClean = True Then Temp = Temp & Part(Count) & Place(Count)
If StringClean = False Then Temp = Temp & Part(Count) & Place(Count) & " "
End If
Next Count
GetFigures = Temp
On Error Resume Next
End Function
Function GetHundreds(ByVal MyNumber)
Dim Result As String
If Val(MyNumber) = 0 Then Exit Function
MyNumber = Right("000" & MyNumber, 3)
' Convert the hundreds place.
If Mid(MyNumber, 1, 1) "0" Then
Result = GetDigit(Mid(MyNumber, 1, 1)) & " Hundred "
End If
' Convert the tens and ones place.
If Mid(MyNumber, 2, 1) "0" Then
Result = Result & GetTens(Mid(MyNumber, 2))
Else
Result = Result & GetDigit(Mid(MyNumber, 3))
End If
GetHundreds = Trim(Result)
End Function
Function GetTens(TensText)
Dim Result As String
Result = "" ' Null out the temporary function value.
If Val(Left(TensText, 1)) = 1 Then ' If value between 10-19...
Select Case Val(TensText)
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 ' If value between 20-99...
Select Case Val(Left(TensText, 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(TensText, 1)) ' Retrieve ones place.
End If
GetTens = Result
End Function
Function GetDigit(Digit)
Select Case Val(Digit)
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
4. 回到Excel工作表,输入函数:=ChineseNumber(A1),其中A1为要转换的单元格。
5. 按下回车键,即可将数字转换成大写。
以上就是在Excel中将数字转换成大写的三种方法。使用设置单元格格式可以快速简便地转换大写。通过使用公式和VBA宏,可以更加灵活地进行转换,并且可以批量处理大量数据。根据实际需求,选择适合的方法来实现数字转换。
- 上一篇:2020年韩国打工还能去吗
- 下一篇:通化东宝近期走势