Excel extract cell Chinese pinyin first letter

Source: Internet
Author: User

Option Explicit
function PY (TT as String) as Variant ' Custom function, purpose: To change a group of Chinese characters into the first letter of a set of Chinese pinyin.
Dim i%, temp$
PY = ""
For i = 1 to Len (TT)
temp = ASC (mid$ (TT, I, 1))
If temp > 255 Or Temp < 0 Then ' is Kanji?
py = py & Pinyin (mid$ (TT, I, 1)) ' converted to pinyin initials,
Else
py = py & LCase (mid$ (TT, I, 1)) ' Convert English alphabet
End If
Next I
End Function
function Pinyin (mystr as String) as Variant ' custom functions, purpose: To change a single Chinese character to the first letter of Pinyin.
On Error Resume Next
MyStr = StrConv (mystr, Vbnarrow)
If ASC (mystr) > 0 Or err.number = 1004 then pinyin = ""
Pinyin = Application.WorksheetFunction.VLookup (MyStr, [{"Acridine", "A"; " Eight "," B ";" Cha "," C ";" Otah "," D ";" 鵽 "," E ";" "," F ";" 猤 "," G ";" Hafnium "," H ";" Inceѕt "," J ";" Ka "," K ";" "," L ";" 嘸 "," M ";" Temperature "," N ";" Oh "," O ";" 妑 "," P ";" Seven "," Q ";" 囕 "," R ";" Three "," S ";" He "," T "; 屲 "," W ";" Xi "," X ";" Ya "," Y ";" As "," Z "}], 2)
End Function

To do this, open the Excel document, press ALT+F11, open the VBE editor, insert the--module, copy the code above, and close the VBE. Return to the worksheet, enter a formula, such as: =py (A2), you can extract the first letter of the A2 cell pinyin.

Originating From: http://www.ittribalwo.com/article/1542.html

Excel extract cell Chinese pinyin first letter

Related Article

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.