2016 - 2024

感恩一路有你

怎样把excel的人民币大写复制出来 Excel将人民币金额转换成大写形式

浏览量:2625 时间:2023-09-29 17:01:11 作者:采采

在日常工作中,我们经常需要将人民币金额转换成大写形式。Excel提供了几种方法来实现这一功能,包括使用公式和宏。本文将分别介绍这两种方法的步骤,并结合示例演示。

一、使用Excel公式进行转换

1. 首先,将人民币金额输入到Excel单元格中。

2. 在另一个单元格中输入以下公式:

TEXT(A1,"[壹贰叁肆伍陆柒捌玖拾佰仟万亿圆整]*"),其中A1为输入金额的单元格。

3. 按下Enter键,即可将人民币金额转换成大写形式。

示例:

假设我们要将1000元转换成大写形式,在单元格A1中输入1000,然后在另一个单元格中输入上述公式,按下Enter键,即可得到壹仟圆整。

二、使用Excel宏进行转换

1. 打开Excel,并按下Alt F11进入宏编辑界面。

2. 在宏编辑界面的代码窗口中,输入以下代码:

```

Function ConvertToChinese(Number As Double) As String

Dim MyNumber As String

Dim DecimalPlace As Integer

Dim Count As Integer

ReDim Place(9) As String

Place(2) " Thousand "

Place(3) " Million "

Place(4) " Billion "

Place(5) " Trillion "

' String representation of amount.

MyNumber Trim(CStr(Number))

' Position of decimal place 0 if none.

DecimalPlace InStr(MyNumber, ".")

' Convert cents and set MyNumber to dollar amount.

If DecimalPlace > 0 Then

Cents GetTens(Left(Mid(MyNumber, DecimalPlace 1) "00", 2))

MyNumber Trim(Left(MyNumber, DecimalPlace - 1))

End If

Count 1

Do While MyNumber <> ""

ReDim Preserve Dollars(Count)

Dollars(Count) GetHundreds(Right(MyNumber, 3))

If Len(MyNumber) > 3 Then

MyNumber Left(MyNumber, Len(MyNumber) - 3)

Else

MyNumber ""

End If

Count Count 1

Loop

Count Count - 1

If Count 1 Then

ConvertToChinese Dollars(1) " Dollars "

Else

ConvertToChinese Dollars(Count) Place(Count) _

GetHundreds( _

Right(MyNumber, 3)) " Dollars "

End If

' Clean up dollars.

Select Case Dollars(1)

Case ""

ConvertToChinese "No Dollars"

Case "One"

ConvertToChinese "One Dollar"

Case Else

ConvertToChinese ConvertToChinese "Dollars"

End Select

' Clean up cents.

Select Case Cents

Case ""

ConvertToChinese ConvertToChinese

Case "One"

ConvertToChinese ConvertToChinese " and One Cent"

Case Else

ConvertToChinese ConvertToChinese " and " Cents " Cents"

End Select

End Function

Private 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 Result

End Function

Private 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

Private 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

```

3. 关闭宏编辑界面,回到正常的Excel界面。

4. 在一个单元格中输入要转换的人民币金额,然后在另一个单元格中输入以下公式:

`ConvertToChinese(A1)`,其中A1为输入金额的单元格。

5. 按下Enter键,即可将人民币金额转换成大写形式。

示例:

假设我们要将1000元转换成大写形式,在单元格A1中输入1000,然后在另一个单元格中输入上述公式,按下Enter键,即可得到One Thousand Dollars。

通过上述方法,你可以轻松将Excel中的人民币金额转换成大写形式,为日常工作提供了便利。试着在你的Excel中尝试一下吧!

Excel 人民币 大写金额 转换

版权声明:本文内容由互联网用户自发贡献,本站不承担相关法律责任.如有侵权/违法内容,本站将立刻删除。