Convert the number (76767.87) in the Excel file to uppercase and lowercase Chinese characters.

Source: Internet
Author: User
Tool -- macro --- Visual Basic Editor ---> right-click module --- insert module --- copy code to it ---- click toolbar debugging ---- compile vbaproject --- return to excel and input in Cells = change (number cell)

Function Cchinese (streng as string) as string
'The program that converts Arabic numerals into Chinese characters, for example, 1560890 to "yiwuzhilu wanzhibaibaizhihui ".
'The program cannot enter more than 16 numbers
If not isnumeric (streng) or streng like "*. *" or streng like "*-*" then
If trim (streng) = "" Then msgbox "Invalid Number"
Cchinese = "": Exit Function
End if

Dim intlen as integer, intcounter as integer
Dim STRCH as string, strtempch as string
Dim strseq1_as string, strseqch2 as string
Dim streng2ch as string
Streng2ch = ""
Strseq.pdf = "pick up a hacker and pick up a hacker"
Strseqch2 = "10 million GB"
Streng = CSTR (cdec (streng ))
Intlen = Len (streng)
For intcounter = 1 to intlen
Strtempch = mid (streng2ch, Val (mid (streng, intcounter, 1) + 1, 1)
If strtempch = "0" and intlen <> 1 then
If mid (streng, intcounter + 1, 1) = "0" or (intlen-intcounter + 1) mod 4 = 1 then
Strtempch = ""
End if
Else
Strtempch = strtempch & trim (mid (strseqter, intlen-intcounter + 1, 1 ))
End if
If (intlen-intcounter + 1) mod 4 = 1 then
Strtempch = strtempch & Mid (strseqch2, (intlen-intcounter + 1) \ 4 + 1, 1)
If intcounter> 3 then
If mid (streng, intcounter-3, 4) = "0000" then strtempch = left (strtempch, Len (strtempch)-1)
End if
End if
STRCH = STRCH & trim (strtempch)
Next
Cchinese = STRCH
End Function

'================================================ ======================================

'================================================ ======================================
Function Change (money As String) As String
'Program for converting the Chinese capital of the currency amount
'The program cannot enter more than 16 numbers
Dim x As String, y As String
Const zimu = ". sbqwsbqysbqwsbq" 'defines the location code
Const letter = "0123456789sbqwy. zjf" 'stands for Chinese Characters
Const upcase = "0, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3

If CDbl (money)> = 1E + 16 Then Change = "# VALUE! ": The Exit Function can only be converted to a currency of less than 0.1 billion RMB!

X = Format (money, "0.00") 'format the currency
Y = ""
For I = 1 To Len (x)-3
Y = y & Mid (x, I, 1) & Mid (zimu, Len (x)-2-I, 1)
Next
If Right (x, 3) = ". 00" Then
Y = y & "z" '*** yuan
Else
Y = y & Left (Right (x, 2), 1) & "j" & Right (x, 1) & "f" '* yuan * angle *
End If
Y = Replace (y, "0q", "0") 'to avoid Zero loss (for example, 40200 RMB and RMB)
Y = Replace (y, "0b", "0") 'to avoid zero (for example, 41000 million RMB and million RMB)
Y = Replace (y, "0 s", "0") 'to avoid zero or ten (for example, 204 records and zero inventory)

Y = Replace (y, "0j", "0") 'Avoid zero angle
Y = Replace (y, "0f", "") 'Avoid zero points

Do While y <> Replace (y, "00", "0 ")
Y = Replace (y, "00", "0") 'avoid double zeros (for example, 1004)
Loop
Y = Replace (y, "0y", "y") 'to avoid 0 billion (for example, 21 billion erbaiyi 10 0 billion)
Y = Replace (y, "0 w", "w") 'to avoid 0 thousand (for example, 2.1 million erbaiyi 10 0 thousand)
Y = IIf (x <0.1, Right (y, Len (y)-3), y) 'Avoid (for example, 0.01 and 0.04)
Y = IIf (Len (x) = 5 And Left (y, 1) = "1", Right (y, Len (y)-1), y) 'avoid ten items (for example, 14 items and 10 items)
Y = IIf (Len (x) = 4, Replace (y, "0. "," "), Replace (y," 0. ",". ") 'Avoid zero yuan (for example, 20.00 yuan to pick up the zero circle; 0.12 yuan to the second angle)
For I = 1 To 19
Y = Replace (y, Mid (letter, I, 1), Mid (upcase, I, 1) 'uppercase Chinese Characters
Next
Change = y
End Function
'================================================ ======================================

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.