用公式将汉字转换为拼音的第一个字母

合集下载

汉字转拼音公式(一)

汉字转拼音公式(一)

汉字转拼音公式(一)
汉字转拼音公式
1. 初级公式
•公式:将汉字转换为拼音的首字母组合
•示例:北京大学 -> BJDXY
2. 基本公式
•公式:将汉字转换为与其发音相近的拼音字母组合
•示例:中国 -> ZG, 上海 -> SH
3. 多音字公式
•公式:针对多音字的不同发音,将汉字对应的拼音进行区分•示例:重阳 -> CHONGYANG, 众阳 -> ZHONGYANG
4. 声调公式
•公式:在汉字的拼音后面加上声调符号,表示音调的高低•示例:中国 -> Zhōngguó, 上海 -> Shànghǎi
5. 简拼公式
•公式:将拼音的首字母组合作为简拼,忽略声调符号
•示例:中国 -> ZG, 上海 -> SH
6. 英文公式
•公式:将汉字拼音直接翻译成对应的英文单词
•示例:北京 -> Beijing, 上海 -> Shanghai
7. 全拼公式
•公式:将汉字拼音直接转换为与其发音相近的完整拼音
•示例:北京 -> Běijīng, 上海 -> Shànghǎi
以上是常见的汉字转拼音公式,它们可以根据实际需要进行选择和组合使用。

不同的公式有不同的应用场景,根据具体需求可以选择合适的公式来进行汉字转拼音处理。

注意:在实际应用中,汉字转拼音公式可能需要考虑语义、音韵规则等因素,以确保转换结果的准确性和可读性。

wps 全拼公式

wps 全拼公式

wps 全拼公式WPS全拼公式在日常办公中,我们经常使用WPS办公软件来编辑文档、制作表格和演示文稿。

而对于经常使用WPS的人来说,熟练掌握全拼公式是必不可少的。

下面将介绍一些常用的WPS全拼公式,帮助大家提高办公效率。

一、拼音首字母加数字在WPS中,我们可以使用拼音首字母加数字的方式快速输入文字。

例如,想要输入“WPS”,只需按下“W1P1S1”即可。

这种方法在输入长词组时尤其方便,可以大大减少输入时间。

二、拼音首字母加拼音首字母除了使用数字,我们还可以使用拼音首字母加拼音首字母的方式来输入文字。

例如,“中国”可以用“ZG”表示,“美国”可以用“MG”表示。

这种方法适用于拼音首字母唯一的情况,可以更加简洁地输入文字。

三、拼音首字母加下划线在WPS中,我们还可以使用拼音首字母加下划线的方式来输入文字。

例如,“北京”可以用“B_J”表示,“上海”可以用“S_H”表示。

这种方法适用于拼音首字母重复的情况,可以避免输入错误。

四、拼音首字母加拼音全拼有时候,我们需要输入一些生僻字或者外文单词,这时可以使用拼音首字母加拼音全拼的方式来输入文字。

例如,“博客”可以用“BKUE”表示,“Excel”可以用“EKSHEL”表示。

这种方法适用于拼音首字母无法唯一确定的情况。

五、拼音首字母加英文首字母在WPS中,我们还可以使用拼音首字母加英文首字母的方式来输入文字。

例如,“微信”可以用“WX”表示,“QQ”可以用“QQ”表示。

这种方法适用于拼音首字母与英文首字母重复的情况,可以避免输入错误。

六、拼音首字母加拼音缩写除了拼音全拼,我们还可以使用拼音缩写的方式来输入文字。

例如,“中文”可以用“ZW”表示,“英文”可以用“YW”表示。

这种方法适用于拼音首字母无法唯一确定但拼音缩写唯一确定的情况。

七、拼音首字母加拼音末字母有时候,我们需要输入一些特殊的词汇,这时可以使用拼音首字母加拼音末字母的方式来输入文字。

例如,“数学”可以用“SXX”表示,“物理”可以用“WL”表示。

汉字转拼音公式

汉字转拼音公式

汉字转拼音公式摘要:一、汉字转拼音的背景与意义1.汉字的特点与拼音的局限性2.汉字转拼音在教育、科技等领域的应用二、汉字转拼音的原理与方法1.拼音系统的发展与演变2.音韵学对汉字转拼音的贡献3.现代汉字转拼音的技术实现三、汉字转拼音的工具与案例1.拼音输入法的发展与应用2.拼音查询工具的功能与使用3.汉字转拼音在实际应用中的案例分析四、汉字转拼音的挑战与展望1.复杂汉字拼音转换的问题与解决策略2.方言与特殊发音的拼音转换3.汉字转拼音在未来教育、科技等领域的发展趋势正文:一、汉字转拼音的背景与意义汉字是中华文明的重要载体,具有丰富的表意功能。

然而,由于汉字的形状复杂,学习难度较大,因此在实际应用中,人们需要一种简便的方法来快速查询、输入汉字。

拼音是一种基于拉丁字母的注音系统,可以较为简单地表示汉字的发音。

将汉字转换为拼音,有助于降低汉字学习的难度,提高汉字输入与查询的效率。

此外,汉字转拼音在教育、科技等领域具有广泛的应用价值。

二、汉字转拼音的原理与方法1.拼音系统的发展与演变汉字转拼音的历史可以追溯到古代的音韵学。

音韵学是对汉字音韵规律的研究,为汉字转拼音提供了理论基础。

在现代,汉字转拼音主要依赖于汉语拼音方案。

汉语拼音方案是在20 世纪50 年代,我国政府为规范汉字拼音而制定的一套拼音方案,包括声母、韵母和声调等基本元素。

2.音韵学对汉字转拼音的贡献音韵学对汉字转拼音的贡献主要体现在对汉字音韵规律的研究。

通过音韵学的研究,人们可以更好地理解汉字发音的演变过程,为汉字转拼音提供更为科学的依据。

3.现代汉字转拼音的技术实现现代汉字转拼音的技术实现主要依赖于计算机技术。

通过编程实现汉字与拼音之间的转换算法,可以实现汉字的快速查询、输入等功能。

目前,市场上已有多种汉字转拼音的工具,如拼音输入法、拼音查询工具等。

三、汉字转拼音的工具与案例1.拼音输入法的发展与应用拼音输入法是汉字转拼音的重要应用之一。

通过拼音输入法,用户可以利用拉丁字母输入汉字,提高汉字输入的效率。

拼音输入法的数学原理

拼音输入法的数学原理

拼⾳输⼊法的数学原理1.输⼊法与编码:a.对汉字的编码分为两个部分:i.对拼⾳的编码ii.对消除歧义的编码b.拼⾳输⼊法的优势:i.不需要专门的学习ii.输⼊⾃然,不会中断思维,即找每个键的时间短iii.编码长,有信息冗余,容错性好2.输⼊⼀个汉字需要敲多少个键——⾹农第⼀定理a.⾹农第⼀定理:对于⼀个信息,任何编码的长度都不⼩于它的信息熵b.汉字编码的平均长度:⼀共6700个汉字,常⽤的汉字⽤短编码时,其编码的平均长度为P1*L1+P2*L2+...+P6700*L6700(其中Li为第i个词的编码长度,Pi 为其出现的概率)c.基于LCD语料库时计算汉字编码的信息熵在10⽐特以内⽽使⽤26个字母进⾏编码时,每个字母可以代表log26约4.7⽐特的信息,那么输⼊⼀个汉字平均需要10/4.7约2.1次键盘进⼀步的,如果以词为单位统计信息熵,在不考虑上下⽂相关性,汉字的平均信息熵将会下降到8⽐特如果以词为统计单位,且考虑上下⽂的相关性,以此建⽴统计语⾔模型,那么每个汉字的信息熵会下降到6⽐特左右3.拼⾳转汉字的算法:a.原理:和导航中寻找最短路径的算法相同,都是动态规划b.通信模型:输⼊法则是将拼⾳串变到汉字串的转换器,每⼀个拼⾳可以对应多个汉字,把拼⾳串对应的汉字从左到右连接起来,就是⼀张有向图,称为⽹格图或者篱笆图,如图:c.算法原理:Y1,...,Yn为输⼊的拼⾳串,Wi1,Wi2,Win是第i个⾳Yi的候选汉字(⽤Wi代表第i个拼⾳的候选汉字),如上图所⽰,将候选字连接起来可以组成很多很多的句⼦,每个句⼦都有⼀条路径⼀⼀对应,拼⾳输⼊法就是要根据上下⽂在给定的拼⾳条件下找到⼀个最优的句⼦,即,对应到上图中就是寻找从起点到终点的⼀条最短距离利⽤隐马尔科夫模型简化之得到定义距离:D(Wi-1,Wi)=-logP(Wi|Wi-1)*P(Yi|Wi),以此作为两个节点间的距离计算公式,利⽤有限状态机和动态规划进⾏求解4.个性化的语⾔模型a.研究表明:不同的⼈应该有⾃⼰的语⾔模型,但是⼜要处理好和通⽤模型间的关系b.训练⼀个个性化的语⾔模型:i.训练⼀个词汇量在⼏万的⼆元模型,需要⼏千万的语料,没有⾜够多的语料库,训练出来的⾼阶模型也没有⽤ii.更好的思路找到⼤量符合⽤户的语料,具体的如下:1).将训练语⾔模型的⽂本或者语料按照主题分成很多不同的类别,C1,...,C10002).然后求每个分类的特征向量(TF-IDF)X1,...,X10003).统计某⼈输⼊的⽂本,得到他输⼊的词的特征向量Y4).计算Y和Xi的余弦5).选择前K个和Y距离最近的类对应的⽂本,作为⽤户的语⾔模型的训练数据6).⽤筛选的训练数据训练语⾔模型M1iii.模型M1对常⽤词效果更好,但是通⽤模型M0对相对偏僻的词效果好1).可以⽤最⼤熵模型对M0、M1进⾏综合,但是成本较⾼2).线性插值的简化模型假设M0、M1都是⼆元模型,计算(Wi-1,Wi)的概率为P1(Wi-1,Wi)和P0(Wi-1,Wi),对新的模型M',其条件概率(Wi-1,Wi)'=λ(Wi-1)*P0(Wi|Wi-1)+(1-λ(Wi-1))*P1(Wi|Wi-1)⽽信息熵是⼀个凸函数,所有P'的熵⽐P0、P1线性组合的不确定性⼩,是更好的模型。

wps表格教程三秒钟获取字词对应的第一个字母

wps表格教程三秒钟获取字词对应的第一个字母

4,1101,1609,1793,2080,2560,2902,3845,4107,4679,5154,53 97,5405,5689,617
0,6229,7001,7481,7763,8472,9264},{"A","B","C","D","E","F", "G","H","J",
"K","L","M","N","O","P","Q","R","S","T","W","X","Y","Z"}) 9,6170,6229,7001,7481,7763,8472,9264},{ "A","B","C","D"
,"E","F","G","H","J","K","L","M","N","O","P","Q","R","S","T"," W","X","
Y","Z"})
5405,5689,6170,6229,7001,7481,7763,8472,9264},{"A","B"," C","D","E","F"

vba自定义getpy公式

vba自定义getpy公式

vba自定义getpy公式VBA自定义GetPY公式VBA是Visual Basic for Applications的缩写,是一种用于Microsoft Office应用程序的编程语言。

通过使用VBA,我们可以自定义各种函数和公式,以满足特定的需求。

本文将介绍如何使用VBA自定义一个名为GetPY的公式,用于将中文转换为拼音。

公式名称:GetPY公式功能:将中文转换为拼音。

公式语法:=GetPY(文本)公式参数:- 文本:要转换为拼音的中文文本。

注意事项:1. 该公式只能将单个中文字符转换为拼音,无法处理多个中文字符的转换。

2. 该公式只能转换简体中文,无法处理繁体中文。

使用VBA自定义函数的步骤如下:1. 打开Excel,并按下Alt + F11,打开VBA编辑器。

2. 在VBA编辑器中,选择插入->模块,创建一个新的模块。

3. 在新的模块中,输入以下VBA代码:```vbaFunction GetPY(ByVal Text As String) As StringDim Result As StringDim i As IntegerFor i = 1 To Len(Text)Result = Result & GetPYChar(Mid(Text, i, 1)) Next iGetPY = ResultEnd FunctionFunction GetPYChar(ByVal Char As String) As String Dim Result As StringSelect Case CharCase "的": Result = "de "Case "一": Result = "yi "Case "是": Result = "shi "Case "了": Result = "le "Case "在": Result = "zai "Case "我": Result = "wo "Case "有": Result = "you " Case "和": Result = "he "Case "人": Result = "ren " Case "这": Result = "zhe " Case "中": Result = "zhong " Case "大": Result = "da "Case "为": Result = "wei " Case "上": Result = "shang " Case "个": Result = "ge "Case "国": Result = "guo " Case "到": Result = "dao " Case "说": Result = "shuo " Case "们": Result = "men " Case "为": Result = "wei " Case "子": Result = "zi "Case "和": Result = "he "Case "地": Result = "di "Case "也": Result = "ye "Case "时": Result = "shi "'其他汉字的拼音转换规则'...'...Case Else: Result = Char & " "End SelectGetPYChar = ResultEnd Function```4. 保存并关闭VBA编辑器。

j与e的转换关系公式

j与e的转换关系公式

j与e的转换关系公式J和E是两种不同的输入方法,J为中文输入法,而E为英文输入法。

在日常的使用中,我们经常会因为需要输入不同类型的文字而需要在J和E之间进行转换。

因此,我们需要了解J 和E之间的转换关系公式。

首先,我们需要了解J和E的输入方式以及它们的基本结构。

J为中文输入法,其输入方式是通过拼音或笔画输入汉字。

而E为英文输入法,其输入方式是通过键盘上的字母键输入英文字母。

其次,在J和E之间进行转换时,我们需要考虑到不同语言之间的差异。

中文和英文的语言结构、语法以及词汇等方面都具有很大的差异,因此在进行J和E之间的转换时,我们需要找到一种适当的转换规则。

为了实现J和E之间的转换,我们可以使用一些常见的转换方法,如汉语拼音转换为英文、英文音译转换为中文等方法。

其中,汉语拼音转换为英文的方法是比较常见的一种。

这种方法是通过将汉语拼音中的音节转化为相应的英文字母来实现J和E之间的转换。

例如,“中国”这个中文单词的拼音为“zhōng guó”,我们可以将其转换为英文单词“China”来实现J和E之间的转换。

另外,英文音译转换为中文也是一种常见的转换方法。

这种方法是通过将英文单词中的音节转化为相应的中文词语来实现J和E之间的转换。

例如,英文单词“computer”可以转换为中文词语“计算机”来实现J和E之间的转换。

需要注意的是,在进行J和E之间的转换时,我们需要根据具体的输入内容和场景来选择合适的转换方法,并且在处理复杂的语句和词组时,可能需要使用多种不同的转换方法。

总之,J和E之间的转换关系公式主要涉及到中英文之间的语言差异和转换规则。

通过合适的转换方法,我们可以实现J和E之间的快速转换,并且提高我们的工作效率和生活质量。

EXCEL中怎么把汉字变成拼音,并取拼音的第一个大写字母

EXCEL中怎么把汉字变成拼音,并取拼音的第一个大写字母

打开Excel->工具->宏->Viaual Basic编辑器在弹出来的窗口中对着VBAproject点右键->插入->模块下面会出现一个名为"模块1",点击在右边的空白栏中粘贴以下内容:Function pinyin(p As String) As Stringi = Asc(p)Select Case iCase -20319 To -20284: pinyin = "A"Case -20283 To -19776: pinyin = "B"Case -19775 To -19219: pinyin = "C"Case -19218 To -18711: pinyin = "D"Case -18710 To -18527: pinyin = "E"Case -18526 To -18240: pinyin = "F"Case -18239 To -17923: pinyin = "G"Case -17922 To -17418: pinyin = "H"Case -17417 To -16475: pinyin = "J"Case -16474 To -16213: pinyin = "K"Case -16212 To -15641: pinyin = "L"Case -15640 To -15166: pinyin = "M"Case -15165 To -14923: pinyin = "N"Case -14922 To -14915: pinyin = "O"Case -14914 To -14631: pinyin = "P"Case -14630 To -14150: pinyin = "Q"Case -14149 To -14091: pinyin = "R"Case -14090 To -13319: pinyin = "S"Case -13318 To -12839: pinyin = "T"Case -12838 To -12557: pinyin = "W"Case -12556 To -11848: pinyin = "X"Case -11847 To -11056: pinyin = "Y"Case -11055 To -2050: pinyin = "Z"Case Else: pinyin = pEnd SelectEnd FunctionFunction getpy(str)For i = 1 To Len(str)getpy = getpy & pinyin(Mid(str, i, 1))Next iEnd Function********复制到此结束,本行不复制*******现在转换函数已编写完成!关掉此编缉的窗口。

excel 汉字排序公式

excel 汉字排序公式

excel 汉字排序公式
在Excel中,汉字按照拼音排序并不是默认的排序方式。

如果需要对汉字进行排序,需要使用自定义的排序公式。

以下是一个例子:假设有一个姓名列表,需要按照姓氏进行排序。

其中每个姓名都是由两个汉字组成的,例如“王小明”、“张三丰”等等。

在 Excel 中,可以使用以下公式进行排序:
=IF(LEN(A1)<=1,A1,IF(LEN(A1)<=2,LEFT(A1,1),LEFT(A1,2))) 这个公式会检查每个单元格中的文字数量,如果只有一个汉字,则直接返回该汉字;如果有两个及以上的汉字,则返回前两个汉字。

这样,就能够实现按照姓氏进行排序的功能。

需要注意的是,这个公式只能够对双汉字姓名进行排序。

如果需要对三个及以上汉字的姓名进行排序,需要进行相应的修改。

- 1 -。

excel_汉字转换成拼音简拼(只取首字母)

excel_汉字转换成拼音简拼(只取首字母)

excel_汉字转换成拼音简拼(只取首字母)名称转换为首字母(VBA自定义函数)1,打开EXCEL2,按ALT+F11,单击插入-插入模块,在右窗口粘贴以下代码,直接关闭窗口3,输入公式=hztopy(A1),填充所有单元格4,选择所有缩写,复制-粘贴特殊值(因为它是自定义函数,只有结果可以显示在当前文件中,而其他计算机显示错误是因为5.使用条件格式检索包含中文字符的单元格:首先单击一个单元格(设置为D5)。

条件格式-新格式规则-使用公式确定要格式化的单元格:在下面的对话框中输入公式= LEMB(D5)> LEN(D5),自己设置格式,确认后退出,然后用单元格的格式刷所有单元格汉字外观的格式设置为6。

选择自定义排序-按“单元格颜色”排序-排序“无单元格颜色”和“底部”-确定7,手动将汉字改写成相应的字母8、检查复音字符注意:上述方法只能在当前文件夹中使用。

如何保存宏以便自定义函数可以在所有文件夹中使用?1.创建新的EXCEL2。

按ALT+F11,单击插入-插入模块,并在右侧窗口中粘贴以下代码。

直接关闭窗口3,另存为-其他格式-文件名更改为宏名,保存类型选择” EXCEL加载项(*,xlam)”,文件将自动保存在c: \ \用户\ \ 111 \ \ appdata \ \ road ing \ \ Microsoft \ \ addins文件夹中4.打开需要工作的EXL,然后单击开始-扩展选项-加载项-转到(G)...-选择上面保存的宏名-确定这样,在这台计算机的所有EXCEL中,可以直接使用自定义公式。

代码(只复制星号的内容)* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *函数Hz topy(hzpy As String)As String Dim hzstring As String,py String As StringDim hzpy sum As Integer,hzi As Integer,hzpyhex As Integer hzstring = Trim(hzpy)hzpy sum = Len(Trim(hzstring))py String = \For hzi = 1 To hzpy sumhzpyhex = \ Select Case hzpyhexCase & HB 案例&HB2C1至&HB4ED: pystring = pystring + \案例&HB4EE至&HB6E9: pystring = pystring + \案例&HB6EA至&HB7A1: pystring = pystring + \案例&HB7A2至&HB8C0: pystring = pystring + \案例&HB8C1至&HB9FD: pystring = pystring + \案例&HB9FE至&HBBF6: pystring = pystring + \案例&HBBF7至&HBFA5: pystring = pystring 案例&HC2E8至&HC4C2: pystring = pystring + \案例&HC4C3至&HC5B5: pystring = pystring + \案例&HC5B6至&HC5BD:pystring = pystring + \案例&HC5BE至&HC6D9: pystring = pystring + \案例&HC6DA至&HC8BA: pystring = pystring + \案例&HC8BB至&HC8F5: pystring = pystring + \案例&HC8F6至&HCBF9: pystring = pystringCase & HCDDA To & HCEF3:py string = py string+\ Case & HCEF4 To & HD1B 8:py string = py string+\ Case & HD1B 9 To & HD4D 0:py string = py string+\ Case & HD4D 1 To & HD7F 9:py string = py string+\ Case Elsepy string = py string+Mid(Hz string,hzi,1)结束选择下一个hztopy = pystring结束。

汉字首字母提取函数公式

汉字首字母提取函数公式

汉字首字母提取函数公式
汉字首字母提取函数公式是用来将汉字转化为拼音首字母的数
学公式。

其主要思想是根据汉字的发音规律,将每个汉字的首字母提取出来,然后组成拼音首字母。

公式如下:
def get_first_letter(str):
result = ''
for s in str:
if s >= u'u4e00' and s <= u'u9fa5':
result += chr((ord(s) - 19968) // 676 + 65)
else:
result += s.upper()
return result
其中,参数str表示需要提取首字母的汉字字符串,函数首先定义一个空字符串result用于保存最终的结果。

然后,通过for循环遍历每个汉字,判断它是否在指定的Unicode范围内,如果是,则计算出它的首字母,并将其加入到结果中。

如果不是汉字,则直接将其转化为大写字母,并加入到结果中。

需要注意的是,该函数只适用于简体中文汉字,对于繁体中文或其他语言的汉字可能不适用。

此外,由于汉字的发音规律比较复杂,该函数的准确性也有限,需要根据具体情况进行调整。

- 1 -。

excel:汉字拼音首字母提取

excel:汉字拼音首字母提取

方法一:VBA自定义函数"=hztopy()"下面是一个VBA自定义函数,工具->宏->Visual Basic编辑器->,插入模块,在VBA编辑器里面->插入->模块->贴入下述代码,(按ALT+F11,插入模块,在右面窗口中粘贴下面代码)那么,比如在A3中有"进退两难",则在B3中输入"=hztopy(A3)",则会得到"JTLN"。

不过此法有时候也会出错,比如"皓、鑫、婷、雯、奕"等,就无法提取汉字拼音首字母。

Function hztopy(hzpy As String) As StringDim hzstring As String, pystring As StringDim hzpysum As Integer, hzi As Integer, hzpyhex As Integerhzstring = Trim(hzpy)hzpysum = Len(Trim(hzstring))pystring = ""For hzi = 1 To hzpysumhzpyhex = "&H" + Hex(Asc(Mid(hzstring, hzi, 1)))Select Case hzpyhexCase &HB0A1 To &HB0C4: pystring = pystring + "A"Case &HB0C5 To &HB2C0: pystring = pystring + "B"Case &HB2C1 To &HB4ED: pystring = pystring + "C"Case &HB4EE To &HB6E9: pystring = pystring + "D"Case &HB6EA To &HB7A1: pystring = pystring + "E"Case &HB7A2 To &HB8C0: pystring = pystring + "F"Case &HB8C1 To &HB9FD: pystring = pystring + "G"Case &HB9FE To &HBBF6: pystring = pystring + "H"Case &HBBF7 To &HBFA5: pystring = pystring + "J"Case &HBFA6 To &HC0AB: pystring = pystring + "K"Case &HC0AC To &HC2E7: pystring = pystring + "L"Case &HC2E8 To &HC4C2: pystring = pystring + "M"Case &HC4C3 To &HC5B5: pystring = pystring + "N"Case &HC5B6 To &HC5BD: pystring = pystring + "O"Case &HC5BE To &HC6D9: pystring = pystring + "P"Case &HC6DA To &HC8BA: pystring = pystring + "Q"Case &HC8BB To &HC8F5: pystring = pystring + "R"Case &HC8F6 To &HCBF9: pystring = pystring + "S"Case &HCBFA To &HCDD9: pystring = pystring + "T"Case &HEDC5: pystring = pystring + "T"Case &HCDDA To &HCEF3: pystring = pystring + "W"Case &HCEF4 To &HD1B8: pystring = pystring + "X"Case &HD1B9 To &HD4D0: pystring = pystring + "Y"Case &HD4D1 To &HD7F9: pystring = pystring + "Z"Case Elsepystring = pystring + Mid(hzstring, hzi, 1)End SelectNexthztopy = pystringEnd Function方法二:VBA自定义函数"=getpy()"下面是一个VBA自定义函数,工具->宏->Visual Basic编辑器->,插入模块,在VBA编辑器里面->插入->模块->贴入上述代码,那么。

用公式将汉字转换为拼音的第一个字母

用公式将汉字转换为拼音的第一个字母

用公式将汉字转换为拼音的第一个字母有时需要在Excel中将大量姓名或名称转换为拼音首字母的简写形式,例如将“周伯通”转换为“ZBT”。

用定义名称和公式的方法可以轻松实现转换,在Windows XP中,以Excel xx为例方法如下:1.定义名称:单击菜单“插入→名称→定义”,在弹出的对话框中“在当前工作簿中的名称”下的文本框中输入一个名称,如“py”,在“引用位置”下输入下列代码后确定:={““,”吖”,”八”,”嚓”,”咑”,”鵽”,”发”,”猤”,”铪”,”夻”,”咔”,”垃”,”嘸”,”旀”,“噢”,”妑”,”七”,”囕”,”仨”,”他”,”屲”,”夕”,”丫”,”帀”;”“,”A”,”B”,”C”,”D”,”E”,“F”,”G”,”H”,”J”,”K”,”L”,”M”,”N”,”O”,”P”,”Q”,”R”,”S”,”T”,”W”,”X”,”Y”,”Z”}2.假如名单在A2:A100区域中,在B2单元格中输入公式:=LOOKUP(LEFT(A2,1),py)&LOOKUP(MID(A2,2,1),py)&LOOKUP(MID(A2,3,1),py)&LOOKUP(MID(A2,4,1),py)然后拖动填充柄向下填充公式即可。

说明:1.定义的名称为一个数组,以分号为界分为两行,第一行为汉字,第二行为与第一行汉字对应的拼音第一个大写字母。

如果是Windows 7或Vista,则需要将定义的名称改为:={““,”吖”,”八”,”攃”,”咑”,”鵽”,”发”,”旮”,”哈”,”丌”,”咔”,”垃”,”妈”,”乸”,“噢”,”帊”,”七”,”冄”,”仨”,”他”,”屲”,”夕”,”丫”,”帀”;”“,”A”,”B”,”C”,”D”,”E”,“F”,”G”,”H”,”J”,”K”,”L”,”M”,”N”,”O”,”P”,”Q”,”R”,”S”,”T”,”W”,”X”,”Y”,”Z”}2.公式用LOOKUP函数将每个汉字转换成拼音的第一个大写字母。

excel_汉字转换成拼音简拼(只取首字母)

excel_汉字转换成拼音简拼(只取首字母)

名字转换为首字母(VBA自定义函数)1、打开EXCEL2、按 ALT+F11 ,点击插入-插入模块,在右面窗口中粘贴下面代码,直接关闭窗口3、输入公式=hztopy(A1),填充所有单元格4、选中所有缩写,复制-选择性粘贴-数值(因为是自定义函数,只有在当前文件中可以显示结果,其他电脑因没有公式而显示错误)5、使用条件格式,检索出含有汉字的单元格:先点中一个单元格(设为D5),条件格式-新建格式规则-使用公式确定要设置格式的单元格:在下面对话框中输入公式 =LENB(D5)>LEN(D5),自己设置格式,确定后退出,再把该单元格的格式用格式刷刷所有单元格。

有汉字的出现所设格式6、选择自定义排序-排序依据“单元格颜色”-次序“无单元格颜色”“在底端”-确定。

7、将汉字手动改写为相应的字母。

8、核对多音字。

注:以上方法只可以在当前文件夹使用,如何将宏保存,使自定义函数可以在所有文件夹中使用1、新建一个EXCEL2、按 ALT+F11 ,点击插入-插入模块,在右面窗口中粘贴下面代码,直接关闭窗口3、另存为-其他格式-文件名改为宏名称、保存类型选择“EXCEL加载宏(*,xlam)”,文件将自动保存在C:\Users\111\AppData\Roaming\Microsoft\AddIns文件夹。

4、打开需要工作的EXLEL,点击开始-EXCEL选项-加载项-转到(G)...-选中上面保存的宏名称-确定。

这样,在该电脑的所有EXCEL中,都可以直接使用自定义公式。

代码(只复制星号内的内容)******************************************************************************* Function hztopy(hzpy As String) As StringDim hzstring As String, pystring As StringDim hzpysum As Integer, hzi As Integer, hzpyhex As Integerhzstring = Trim(hzpy)hzpysum = Len(Trim(hzstring))pystring = ""For hzi = 1 To hzpysumhzpyhex = "&H" + Hex(Asc(Mid(hzstring, hzi, 1)))Select Case hzpyhexCase &HB0A1 To &HB0C4: pystring = pystring + "A"Case &HB0C5 To &HB2C0: pystring = pystring + "B"Case &HB2C1 To &HB4ED: pystring = pystring + "C"Case &HB4EE To &HB6E9: pystring = pystring + "D"Case &HB6EA To &HB7A1: pystring = pystring + "E"Case &HB7A2 To &HB8C0: pystring = pystring + "F"Case &HB8C1 To &HB9FD: pystring = pystring + "G"Case &HB9FE To &HBBF6: pystring = pystring + "H"Case &HBBF7 To &HBFA5: pystring = pystring + "J"Case &HBFA6 To &HC0AB: pystring = pystring + "K"Case &HC0AC To &HC2E7: pystring = pystring + "L"Case &HC2E8 To &HC4C2: pystring = pystring + "M"Case &HC4C3 To &HC5B5: pystring = pystring + "N"Case &HC5B6 To &HC5BD: pystring = pystring + "O"Case &HC5BE To &HC6D9: pystring = pystring + "P"Case &HC6DA To &HC8BA: pystring = pystring + "Q"Case &HC8BB To &HC8F5: pystring = pystring + "R"Case &HC8F6 To &HCBF9: pystring = pystring + "S"Case &HCBFA To &HCDD9: pystring = pystring + "T"Case &HEDC5: pystring = pystring + "T"Case &HCDDA To &HCEF3: pystring = pystring + "W"Case &HCEF4 To &HD1B8: pystring = pystring + "X"Case &HD1B9 To &HD4D0: pystring = pystring + "Y"Case &HD4D1 To &HD7F9: pystring = pystring + "Z"Case Elsepystring = pystring + Mid(hzstring, hzi, 1)End SelectNexthztopy = pystringEnd Function*******************************************************************************。

如何在excel中把汉字转换成拼音

如何在excel中把汉字转换成拼音

Excel自定义函数方法:1.启动Excel 2003(其它版本请仿照操作),打开相应的工作表;2.执行“工具→宏→Visual Basic编辑器”命令(或者直接按“Alt+F11”组合键),进入Visual Basic编辑状态;3.执行“插入→模块”命令,插入一个新模块。

再双击插入的模块,进入模块代码编辑状态;4.将代码输入其中;5.代码输入完成后,关闭V isual Basic编辑窗口,返回Excel编辑状态;6.自定义函数就可以用了,如:选中D2单元格,输入公式:=getpy(A2)。

有极个别的汉字不能转换,手动就可以了!很方便了。

Function pinyin(p As String) As Stringi = Asc(p)Select Case iCase -20319 To -20318: pinyin = "a "Case -20317 To -20305: pinyin = "ai "Case -20304 To -20296: pinyin = "an "Case -20295 To -20293: pinyin = "ang "Case -20292 To -20284: pinyin = "ao "Case -20283 To -20266: pinyin = "ba " Case -20265 To -20258: pinyin = "bai " Case -20257 To -20243: pinyin = "ban " Case -20242 To -20231: pinyin = "bang " Case -20230 To -20052: pinyin = "bao " Case -20051 To -20037: pinyin = "bei " Case -20036 To -20033: pinyin = "ben " Case -20032 To -20027: pinyin = "beng " Case -20026 To -20003: pinyin = "bi " Case -20002 To -19991: pinyin = "bian " Case -19990 To -19987: pinyin = "biao " Case -19986 To -19983: pinyin = "bie " Case -19982 To -19977: pinyin = "bin " Case -19976 To -19806: pinyin = "bing " Case -19805 To -19785: pinyin = "bo " Case -19784 To -19776: pinyin = "bu " Case -19775 To -19775: pinyin = "ca "Case -19774 To -19764: pinyin = "cai "Case -19763 To -19757: pinyin = "can "Case -19756 To -19752: pinyin = "cang "Case -19751 To -19747: pinyin = "cao "Case -19746 To -19742: pinyin = "ce "Case -19741 To -19740: pinyin = "ceng "Case -19739 To -19729: pinyin = "cha "Case -19728 To -19726: pinyin = "chai "Case -19715 To -19541: pinyin = "chang " Case -19540 To -19532: pinyin = "chao " Case -19531 To -19526: pinyin = "che " Case -19525 To -19516: pinyin = "chen " Case -19515 To -19501: pinyin = "cheng " Case -19500 To -19485: pinyin = "chi " Case -19484 To -19480: pinyin = "chong " Case -19479 To -19468: pinyin = "chou " Case -19467 To -19290: pinyin = "chu " Case -19289 To -19289: pinyin = "chuai " Case -19288 To -19282: pinyin = "chuan " Case -19281 To -19276: pinyin = "chuang " Case -19275 To -19271: pinyin = "chui " Case -19270 To -19264: pinyin = "chun " Case -19263 To -19262: pinyin = "chuo " Case -19261 To -19250: pinyin = "ci " Case -19249 To -19244: pinyin = "cong " Case -19243 To -19243: pinyin = "cou " Case -19242 To -19239: pinyin = "cu " Case -19238 To -19236: pinyin = "cuan " Case -19235 To -19228: pinyin = "cui " Case -19227 To -19225: pinyin = "cun " Case -19224 To -19219: pinyin = "cuo " Case -19218 To -19213: pinyin = "da " Case -19212 To -19039: pinyin = "dai "Case -19038 To -19024: pinyin = "dan " Case -19023 To -19019: pinyin = "dang " Case -19018 To -19007: pinyin = "dao " Case -19006 To -19004: pinyin = "de " Case -19003 To -18997: pinyin = "deng " Case -18996 To -18978: pinyin = "di " Case -18977 To -18962: pinyin = "dian " Case -18961 To -18953: pinyin = "diao " Case -18952 To -18784: pinyin = "die " Case -18783 To -18775: pinyin = "ding " Case -18774 To -18774: pinyin = "diu " Case -18773 To -18527: pinyin = "dong " Case -18526 To -18519: pinyin = "fa " Case -18518 To -18502: pinyin = "fan " Case -18501 To -18491: pinyin = "fang " Case -18490 To -18479: pinyin = "fei " Case -18478 To -18464: pinyin = "fen " Case -18463 To -18449: pinyin = "feng "Case -18447 To -18447: pinyin = "fou " Case -18446 To -18240:pinyin = "fu " Case -18239 To -18238: pinyin = "ga " Case -18237 To -18232: pinyin = "gai " Case -18231 To -18221: pinyin = "gan " Case -18220 To -18212: pinyin = "gang " Case -18211 To -18202: pinyin = "gao " Case -18201 To -18185: pinyin = "ge " Case -18184 To -18184: pinyin = "gei " Case -18183 To -18182: pinyin = "gen " Case -18181 To -18013: pinyin = "geng " Case -18012 To -17998: pinyin = "gong " Case -17997 To -17989: pinyin = "gou " Case -17988 To -17971: pinyin = "gu " Case -17970 To -17965: pinyin = "gua " Case -17964 To -17962: pinyin = "guai " Case -17961 To -17951: pinyin = "guan " Case -17950 To -17948: pinyin = "guang " Case -17947 To -17932: pinyin = "gui " Case -17931 To -17929: pinyin = "gun " Case -17928 To -17923: pinyin = "guo " Case -17922 To -17760: pinyin = "ha " Case -17759 To -17753: pinyin = "hai " Case -17752 To -17734: pinyin = "han " Case -17733 To -17731: pinyin = "hang " Case -17730 To -17722: pinyin = "hao " Case -17721 To -17704: pinyin = "he " Case -17703 To -17702: pinyin = "hei " Case -17701 To -17698: pinyin = "hen " Case -17697 To -17693: pinyin = "heng " Case -17692 To -17684: pinyin = "hong " Case -17683 To -17677: pinyin = "hou " Case -17676 To -17497: pinyin = "hu " Case -17496 To -17488: pinyin = "hua " Case -17487 To -17483: pinyin = "huai " Case -17482 To -17469: pinyin = "huan " Case -17468 To -17455: pinyin = "huang " Case -17454 To -17434: pinyin = "hui " Case -17433 To -17428: pinyin = "hun " Case -17427 To -17418: pinyin = "huo " Case -17417 To -17203: pinyin = "ji " Case -17202 To -17186: pinyin = "jia " Case -17185 To -16984: pinyin = "jian "Case -16970 To -16943: pinyin = "jiao " Case -16942 To -16916: pinyin = "jie " Case -16915 To -16734: pinyin = "jin " Case -16733 To -16709: pinyin = "jing " Case -16708 To -16707: pinyin = "jiong " Case -16706 To -16690: pinyin = "jiu " Case -16689 To -16665: pinyin = "ju " Case -16664 To -16658: pinyin = "juan " Case -16657 To -16648: pinyin = "jue " Case -16647 To -16475: pinyin = "jun " Case -16474 To -16471: pinyin = "ka " Case -16470 To -16466: pinyin = "kai " Case -16465 To -16460: pinyin = "kan " Case -16459 To -16453: pinyin = "kang " Case -16452 To -16449: pinyin = "kao " Case -16448 To -16434: pinyin = "ke " Case -16433 To -16430: pinyin = "ken " Case -16429 To -16428: pinyin = "keng " Case -16427 To -16424: pinyin = "kong " Case -16423 To -16420: pinyin = "kou " Case -16419 To -16413: pinyin = "ku " Case -16412 To -16408: pinyin = "kua " Case -16407 To -16404: pinyin = "kuai " Case -16403 To -16402: pinyin = "kuan " Case -16401 To -16394: pinyin = "kuang " Case -16393 To -16221: pinyin = "kui " Case -16220 To -16217: pinyin = "kun " Case -16216 To -16213: pinyin = "kuo " Case -16212 To -16206: pinyin = "la " Case -16205 To -16203: pinyin = "lai " Case -16202 To -16188: pinyin = "lan " Case -16187 To -16181: pinyin = "lang " Case -16180 To -16172: pinyin = "lao " Case -16171 To -16170: pinyin = "le " Case -16169 To -16159: pinyin = "lei " Case -16158 To -16156: pinyin = "leng " Case -16155 To -15960: pinyin = "li " Case -15959 To -15959: pinyin = "lia " Case -15958 To -15945: pinyin = "lian " Case -15944 To -15934: pinyin = "liang " Case -15933 To -15921: pinyin = "liao " Case -15920 To -15916: pinyin = "lie " Case -15915 To -15904: pinyin = "lin "Case -15889 To -15879: pinyin = "liu " Case -15878 To -15708:pinyin = "long " Case -15707 To -15702: pinyin = "lou " Case -15701 To -15682: pinyin = "lu " Case -15681 To -15668: pinyin = "lv " Case -15667 To -15662: pinyin = "luan " Case -15661 To -15660: pinyin = "lue " Case -15659 To -15653: pinyin = "lun " Case -15652 To -15641: pinyin = "luo " Case -15640 To -15632: pinyin = "ma " Case -15631 To -15626: pinyin = "mai " Case -15625 To -15455: pinyin = "man " Case -15454 To -15449: pinyin = "mang " Case -15448 To -15437: pinyin = "mao " Case -15436 To -15436: pinyin = "me " Case -15435 To -15420: pinyin = "mei " Case -15419 To -15417: pinyin = "men " Case -15416 To -15409: pinyin = "meng " Case -15408 To -15395: pinyin = "mi " Case -15394 To -15386: pinyin = "mian " Case -15385 To -15378: pinyin = "miao " Case -15377 To -15376: pinyin = "mie " Case -15375 To -15370: pinyin = "min " Case -15369 To -15364: pinyin = "ming " Case -15363 To -15363: pinyin = "miu " Case -15362 To -15184: pinyin = "mo " Case -15183 To -15181: pinyin = "mou " Case -15180 To -15166: pinyin = "mu " Case -15165 To -15159: pinyin = "na " Case -15158 To -15154: pinyin = "nai " Case -15153 To -15151: pinyin = "nan " Case -15150 To -15150: pinyin = "nang " Case -15149 To -15145: pinyin = "nao " Case -15144 To -15144: pinyin = "ne " Case -15143 To -15142: pinyin = "nei " Case -15141 To -15141: pinyin = "nen " Case -15140 To -15140: pinyin = "neng " Case -15139 To -15129: pinyin = "ni " Case -15128 To -15122: pinyin = "nian " Case -15121 To -15120: pinyin = "niang " Case -15119 To -15118: pinyin = "niao " Case -15117 To -15111: pinyin = "nie " Case -15110 To -15110: pinyin = "nin "Case -14941 To -14938: pinyin = "niu " Case -14937 To -14934:pinyin = "nong " Case -14933 To -14931: pinyin = "nu " Case -14930 To -14930: pinyin = "nv " Case -14929 To -14929: pinyin = "nuan " Case -14928 To -14927: pinyin = "nue " Case -14926 To -14923: pinyin = "nuo " Case -14922 To -14922: pinyin = "o " Case -14921 To -14915: pinyin = "ou " Case -14914 To -14909: pinyin = "pa " Case -14908 To -14903: pinyin = "pai " Case -14902 To -14895: pinyin = "pan " Case -14894 To -14890: pinyin = "pang " Case -14889 To -14883: pinyin = "pao " Case -14882 To -14874: pinyin = "pei " Case -14873 To -14872: pinyin = "pen " Case -14871 To -14858: pinyin = "peng " Case -14857 To -14679: pinyin = "pi " Case -14678 To -14675: pinyin = "pian " Case -14674 To -14671: pinyin = "piao " Case -14670 To -14669: pinyin = "pie " Case -14668 To -14664: pinyin = "pin " Case -14663 To -14655: pinyin = "ping " Case -14654 To -14646: pinyin = "po " Case -14645 To -14631: pinyin = "pu " Case -14630 To -14595: pinyin = "qi " Case -14594 To -14430: pinyin = "qia " Case -14429 To -14408: pinyin = "qian " Case -14407 To -14400: pinyin = "qiang " Case -14399 To -14385: pinyin = "qiao " Case -14384 To -14380: pinyin = "qie " Case -14379 To -14369: pinyin = "qin " Case -14368 To -14356: pinyin = "qing " Case -14355 To -14354: pinyin = "qiong " Case -14353 To -14346: pinyin = "qiu " Case -14345 To -14171: pinyin = "qu " Case -14170 To -14160: pinyin = "quan " Case -14159 To -14152: pinyin = "que " Case -14151 To -14150: pinyin = "qun " Case -14149 To -14146: pinyin = "ran " Case -14145 To -14141: pinyin = "rang " Case -14140 To -14138: pinyin = "rao " Case -14137 To -14136: pinyin = "re "Case -14125 To -14124: pinyin = "reng " Case -14123 To -14123: pinyin = "ri " Case -14122 To -14113: pinyin = "rong " Case -14112 To -14110: pinyin = "rou " Case -14109 To -14100: pinyin = "ru " Case -14099 To -14098: pinyin = "ruan " Case -14097 To -14095: pinyin = "rui " Case-14094 To -14093: pinyin = "run " Case -14092 To -14091: pinyin = "ruo " Case -14090 To -14088: pinyin = "sa " Case -14087 To -14084: pinyin = "sai " Case -14083 To -13918: pinyin = "san " Case -13917 To -13915: pinyin = "sang " Case -13914 To -13911: pinyin = "sao " Case -13910 To -13908: pinyin = "se " Case -13907 To -13907: pinyin = "sen " Case -13906 To -13906: pinyin = "seng " Case -13905 To -13897: pinyin = "sha " Case -13896 To -13895: pinyin = "shai " Case -13894 To -13879: pinyin = "shan " Case -13878 To -13871: pinyin = "shang " Case -13870 To -13860: pinyin = "shao " Case -13859 To -13848: pinyin = "she " Case -13847 To -13832: pinyin = "shen " Case -13831 To -13659: pinyin = "sheng " Case -13658 To -13612: pinyin = "shi " Case -13611 To -13602: pinyin = "shou " Case -13601 To -13407: pinyin = "shu " Case -13406 To -13405: pinyin = "shua " Case -13404 To -13401: pinyin = "shuai " Case -13400 To -13399: pinyin = "shuan " Case -13398 To -13396: pinyin = "shuang " Case -13395 To -13392: pinyin = "shui " Case -13391 To -13388: pinyin = "shun " Case -13387 To -13384: pinyin = "shuo " Case -13383 To -13368: pinyin = "si " Case -13367 To -13360: pinyin = "song " Case -13359 To -13357: pinyin = "sou " Case -13356 To -13344: pinyin = "su " Case -13343 To -13341: pinyin = "suan " Case -13340 To -13330: pinyin = "sui " Case -13329 To -13327: pinyin = "sun " Case -13326 To -13319: pinyin = "suo "Case -13147 To -13139: pinyin = "tai " Case -13138 To -13121:pinyin = "tan " Case -13120 To -13108: pinyin = "tang " Case -13107 To -13097: pinyin = "tao " Case -13096 To -13096: pinyin = "te " Case -13095 To -13092: pinyin = "teng " Case -13091 To -13077: pinyin = "ti " Case -13076 To -13069: pinyin = "tian " Case -13068 To -13064: pinyin = "tiao " Case -13063 To -13061: pinyin = "tie " Case -13060 To -12889: pinyin = "ting " Case -12888 To -12876: pinyin = "tong " Case -12875 To -12872: pinyin = "tou " Case -12871 To -12861: pinyin = "tu " Case -12860 To -12859: pinyin = "tuan " Case -12858 To -12853: pinyin = "tui " Case -12852 To -12850: pinyin = "tun " Case -12849 To -12839: pinyin = "tuo " Case -12838 To -12832: pinyin = "wa " Case -12831 To -12830: pinyin = "wai " Case -12829 To -12813: pinyin = "wan " Case -12812 To -12803: pinyin = "wang " Case -12802 To -12608: pinyin = "wei " Case -12607 To -12598: pinyin = "wen " Case -12597 To -12595: pinyin = "weng " Case -12594 To -12586: pinyin = "wo " Case -12585 To -12557: pinyin = "wu " Case -12556 To -12360: pinyin = "xi " Case -12359 To -12347: pinyin = "xia " Case -12346 To -12321: pinyin = "xian " Case -12320 To -12301: pinyin = "xiang " Case -12300 To -12121: pinyin = "xiao " Case -12120 To -12100: pinyin = "xie " Case -12099 To -12090: pinyin = "xin " Case -12089 To -12075: pinyin = "xing " Case -12074 To -12068: pinyin = "xiong " Case -12067 To -12059: pinyin = "xiu " Case -12058 To -12040: pinyin = "xu " Case -12039 To -11868: pinyin = "xuan " Case -11867 To -11862: pinyin = "xue " Case -11861 To -11848: pinyin = "xun " Case -11847 To -11832: pinyin = "ya " Case -11831 To -11799: pinyin = "yan "Case -11781 To -11605: pinyin = "yao " Case -11604 To -11590:pinyin = "ye " Case -11589 To -11537: pinyin = "yi " Case -11536 To -11359: pinyin = "yin " Case -11358 To -11341: pinyin = "ying " Case -11340 To -11340: pinyin = "yo " Case -11339 To -11325: pinyin = "yong " Case -11324 To -11304: pinyin = "you " Case -11303 To -11098: pinyin = "yu " Case -11097 To -11078: pinyin = "yuan " Case -11077 To -11068: pinyin = "yue " Case -11067 To -11056: pinyin = "yun " Case -11055 To -11053: pinyin = "za " Case -11052 To -11046: pinyin = "zai " Case -11045 To -11042: pinyin = "zan " Case -11041 To -11039: pinyin = "zang " Case -11038 To -11025: pinyin = "zao " Case -11024 To -11021: pinyin = "ze " Case -11020 To -11020: pinyin = "zei " Case -11019 To -11019: pinyin = "zen " Case -11018 To -11015: pinyin = "zeng " Case -11014 To -10839:pinyin = "zha " Case -10838 To -10833: pinyin = "zhai " Case -10832 To -10816: pinyin = "zhan " Case -10815 To -10801: pinyin = "zhang " Case -10800 To -10791: pinyin = "zhao " Case -10790 To -10781: pinyin = "zhe " Case -10780 To -10765: pinyin = "zhen " Case -10764 To -10588: pinyin = "zheng " Case -10587 To -10545: pinyin = "zhi " Case -10544 To -10534: pinyin = "zhong " Case -10533 To -10520: pinyin = "zhou " Case -10519 To -10332: pinyin = "zhu " Case -10331 To -10330: pinyin = "zhua " Case -10329 To -10329: pinyin = "zhuai " Case -10328 To -10323: pinyin = "zhuan " Case -10322 To -10316: pinyin = "zhuang " Case -10315 To -10310: pinyin = "zhui " Case -10309 To -10308: pinyin = "zhun " Case -10307 To -10297: pinyin = "zhuo " Case -10296 To -10282: pinyin = "zi " Case -10281 To -10275: pinyin = "zong " Case -10274 To -10271: pinyin = "zou "Case -10262 To -10261: pinyin = "zuan "Case -10260 To -10257: pinyin = "zui "Case -10256 To -10255: pinyin = "zun "Case -10254 To -10254: pinyin = "zuo "Case Else: pinyin = pEnd SelectEnd FunctionFunction getpy(str)For i = 1 To Len(str)getpy = getpy & pinyin(Mid(str, i, 1))Next iEnd Function只需要在Excel中使用=getpy(列)使用公式,去掉拼音之间的空格假设你的这个数据在A1单元格,在B1单元格输入: =SUBSTITUTE(A1," ","")。

excel-汉字转换成拼音简拼(只取首字母)

excel-汉字转换成拼音简拼(只取首字母)

名字转换为首字母(VBA自定义函数)1、打开EXCEL2、按 ALT+F11 ,点击插入-插入模块,在右面窗口中粘贴下面代码,直接关闭窗口3、输入公式=hztopy(A1),填充所有单元格4、选中所有缩写,复制-选择性粘贴-数值(因为是自定义函数,只有在当前文件中可以显示结果,其他电脑因没有公式而显示错误)5、使用条件格式,检索出含有汉字的单元格:先点中一个单元格(设为D5),条件格式-新建格式规则-使用公式确定要设置格式的单元格:在下面对话框中输入公式 =LENB(D5)>LEN(D5),自己设置格式,确定后退出,再把该单元格的格式用格式刷刷所有单元格。

有汉字的出现所设格式6、选择自定义排序-排序依据“单元格颜色”-次序“无单元格颜色”“在底端”-确定。

7、将汉字手动改写为相应的字母。

8、核对多音字。

注:以上方法只可以在当前文件夹使用,如何将宏保存,使自定义函数可以在所有文件夹中使用1、新建一个EXCEL2、按 ALT+F11 ,点击插入-插入模块,在右面窗口中粘贴下面代码,直接关闭窗口3、另存为-其他格式-文件名改为宏名称、保存类型选择“EXCEL加载宏(*,xlam)”,文件将自动保存在C:\Users\111\AppData\Roaming\Microsoft\AddIns文件夹。

4、打开需要工作的EXLEL,点击开始-EXCEL选项-加载项-转到(G)...-选中上面保存的宏名称-确定。

这样,在该电脑的所有EXCEL中,都可以直接使用自定义公式。

代码(只复制星号内的内容)******************************************************************************* Function hztopy(hzpy As String) As StringDim hzstring As String, pystring As StringDim hzpysum As Integer, hzi As Integer, hzpyhex As Integerhzstring = Trim(hzpy)hzpysum = Len(Trim(hzstring))pystring = ""For hzi = 1 To hzpysumhzpyhex = "&H" + Hex(Asc(Mid(hzstring, hzi, 1)))Select Case hzpyhexCase &HB0A1 To &HB0C4: pystring = pystring + "A"Case &HB0C5 To &HB2C0: pystring = pystring + "B"Case &HB2C1 To &HB4ED: pystring = pystring + "C"Case &HB4EE To &HB6E9: pystring = pystring + "D"Case &HB6EA To &HB7A1: pystring = pystring + "E"Case &HB7A2 To &HB8C0: pystring = pystring + "F"Case &HB8C1 To &HB9FD: pystring = pystring + "G"Case &HB9FE To &HBBF6: pystring = pystring + "H"Case &HBBF7 To &HBFA5: pystring = pystring + "J"Case &HBFA6 To &HC0AB: pystring = pystring + "K"Case &HC0AC To &HC2E7: pystring = pystring + "L"Case &HC2E8 To &HC4C2: pystring = pystring + "M"Case &HC4C3 To &HC5B5: pystring = pystring + "N"Case &HC5B6 To &HC5BD: pystring = pystring + "O"Case &HC5BE To &HC6D9: pystring = pystring + "P"Case &HC6DA To &HC8BA: pystring = pystring + "Q"Case &HC8BB To &HC8F5: pystring = pystring + "R"Case &HC8F6 To &HCBF9: pystring = pystring + "S"Case &HCBFA To &HCDD9: pystring = pystring + "T"Case &HEDC5: pystring = pystring + "T"Case &HCDDA To &HCEF3: pystring = pystring + "W"Case &HCEF4 To &HD1B8: pystring = pystring + "X"Case &HD1B9 To &HD4D0: pystring = pystring + "Y"Case &HD4D1 To &HD7F9: pystring = pystring + "Z"Case Elsepystring = pystring + Mid(hzstring, hzi, 1)End SelectNexthztopy = pystringEnd Function*******************************************************************************。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

用公式将汉字转换为拼音的第一个字母
有时需要在Excel中将大量姓名或名称转换为拼音首字母的简写形式,例如将“周伯通”转换为“ZBT”。

用定义名称和公式的方法可以轻松实现转换,在Windows XP中,以Excel 2003为例方法如下:
1.定义名称:
单击菜单“插入→名称→定义”,在弹出的对话框中“在当前工作簿中的名称”下的文本框中输入一个名称,如“py”,在“引用位置”下输入下列代码后确定:
={"","吖","八","嚓","咑","鵽","发","猤","铪","夻","咔","垃","嘸","旀",
"噢","妑","七","囕","仨","他","屲","夕","丫","帀";"","A","B","C","D","E",
"F","G","H","J","K","L","M","N","O","P","Q","R","S","T","W","X","Y"," Z"}
2.假如名单在A2:A100区域中,在B2单元格中输入公式:
=LOOKUP(LEFT(A2,1),py)&LOOKUP(MID(A2,2,1),py)&LOOKUP(MID(A2,3,1), py)&LOOKUP(MID(A2,4,1),py)
然后拖动填充柄向下填充公式即可。

说明:
1.定义的名称为一个数组,以分号为界分为两行,第一行为汉字,第二行为与第一行汉字对应的拼音第一个大写字母。

如果是Windows 7或Vista,则需要将定义的名称改为:
={"","吖","八","攃","咑","鵽","发","旮","哈","丌","咔","垃","妈","乸",
"噢","帊","七","冄","仨","他","屲","夕","丫","帀";"","A","B","C","D","E",
"F","G","H","J","K","L","M","N","O","P","Q","R","S","T","W","X","Y"," Z"}
2.公式用LOOKUP函数将每个汉字转换成拼音的第一个大写字母。

其原理是:Excel中汉字(文本)之间也可以进行比较;汉字在Excel中的排列顺序与拼音顺序相同,排在前面的“值”小于排在其后的。

上述定义名称的数组中,每个汉字都是所有拼音首字母相同的汉字中的第一个,例如“八”在Excel中排在其他所有拼音首字母为“B”的前面,因而其“值”最小。

因此,LOOKUP函数在查找某个不在数组中的汉字,如“伯”字时,会在数组的第一行中查找小于它的最大值“八”,然后返回最后一行同列的值“B”。

另外,由于在Windows XP与Windows 7、Vista中Excel对汉字的排列顺序有所不同,故定义的名称内容也不同。

如果在Windows 7、Vista中使用XP中定义的数组,LOOKUP函数第二个参数中的值未按升序排列,可能无法返回正确的结果。

3.对于多音字只能返回一种结果。

4.如果有多于四个的汉字,继续在公式后面添加即可。

如有第五个汉字,则加上“&LOOKUP(MID(A2,5,1),py)”。

相关文档
最新文档