excel VBA汉字转化为无音标全拼音并首字母大写
EXCEL中直接把中文转换成拼音全拼
1.第一种方法:打开Excel->工具->宏->Viaual Basic编辑器在弹出来的窗口中对着VBAproject点右键->插入->模块下面会出现一个名为"模块1",点击在右边的空白栏中粘贴以下内容:Function getpychar(char)tmp = 65536 + Asc(char)If (tmp >= 45217 And tmp <= 45252) Thengetpychar = "A"ElseIf (tmp >= 45253 And tmp <= 45760) Then getpychar = "B"ElseIf (tmp >= 45761 And tmp <= 46317) Then getpychar = "C"ElseIf (tmp >= 46318 And tmp <= 46825) Then getpychar = "D"ElseIf (tmp >= 46826 And tmp <= 47009) Then getpychar = "E"ElseIf (tmp >= 47010 And tmp <= 47296) Then getpychar = "F"ElseIf (tmp >= 47297 And tmp <= 47613) Then getpychar = "G"ElseIf (tmp >= 47614 And tmp <= 48118) Then getpychar = "H"ElseIf (tmp >= 48119 And tmp <= 49061) Then getpychar = "J"ElseIf (tmp >= 49062 And tmp <= 49323) Then getpychar = "K"ElseIf (tmp >= 49324 And tmp <= 49895) Then getpychar = "L"ElseIf (tmp >= 49896 And tmp <= 50370) Then getpychar = "M"ElseIf (tmp >= 50371 And tmp <= 50613) Then getpychar = "N"ElseIf (tmp >= 50614 And tmp <= 50621) Then getpychar = "O"ElseIf (tmp >= 50622 And tmp <= 50905) Then getpychar = "P"ElseIf (tmp >= 50906 And tmp <= 51386) Then getpychar = "Q"ElseIf (tmp >= 51387 And tmp <= 51445) Then getpychar = "R"ElseIf (tmp >= 51446 And tmp <= 52217) Then getpychar = "S"ElseIf (tmp >= 52218 And tmp <= 52697) Then getpychar = "T"ElseIf (tmp >= 52698 And tmp <= 52979) Then getpychar = "W"ElseIf (tmp >= 52980 And tmp <= 53640) Then getpychar = "X"ElseIf (tmp >= 53689 And tmp <= 54480) Then getpychar = "Y"ElseIf (tmp >= 54481 And tmp <= 62289) Then getpychar = "Z"Else '如果不是中文,则不处理getpychar = charEnd IfEnd FunctionFunction getpy(str)For i = 1 To Len(str)getpy = getpy & getpychar(Mid(str, i, 1))Next iEnd Function现在转换函数已编写完成!关掉此编缉的窗口。
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->工具->宏->Viaual Basic编辑器在弹出来的窗口中对着VBAproject点右键->插入->模块下面会出现一个名为"模块1",点击在右边的空白栏中粘贴以下内容:Option ExplicitOption Compare TextPublic Function HZQP(expression As String, Optional delimiter As String = " ", Optional limit As Integer = -1) As String'expression' 必需的?包含要转换的字符串?'delimiter' 可选的。
用于标识分隔拼音的字符串字符。
如果忽略,则使用空格字符(" ")作为分隔符。
如果delimiter是一个长度为零的字符串,则返回仅包含一个元素,即完整的 expression字符串。
'limit' 可选的。
要返回拼音字符数,–1表示返回所有的拼音字符数,1表示返回拼音首字母。
Dim STR As String, arrWord(400) As StringDim i As Integer, j As IntegerarrWord(1) = "吖a"arrWord(2) = "哎ai"arrWord(3) = "腤an" arrWord(4) = "肮ang" arrWord(5) = "凹ao" arrWord(6) = "八ba" arrWord(7) = "挀bai" arrWord(8) = "扳ban" arrWord(9) = "邦bang" arrWord(10) = "勹bao" arrWord(11) = "陂bei" arrWord(12) = "奔ben" arrWord(13) = "崩beng" arrWord(14) = "皀bi" arrWord(15) = "边bian" arrWord(16) = "杓biao" arrWord(17) = "憋bie" arrWord(18) = "邠bin" arrWord(19) = "仌bing" arrWord(20) = "拨bo" arrWord(21) = "峬bu" arrWord(22) = "嚓ca" arrWord(23) = "猜cai" arrWord(24) = "飡can" arrWord(25) = "仓cang" arrWord(26) = "撡cao" arrWord(27) = "冊ce" arrWord(28) = "嵾cen" arrWord(29) = "噌ceng" arrWord(30) = "*cha" arrWord(31) = "拆chai" arrWord(32) = "辿chan"arrWord(33) = "伥chang" arrWord(34) = "抄chao" arrWord(35) = "车che" arrWord(36) = "抻chen" arrWord(37) = "阷cheng" arrWord(38) = "吃chi" arrWord(39) = "充chong" arrWord(40) = "抽chou" arrWord(41) = "出chu" arrWord(42) = "搋chuai" arrWord(43) = "巛chuan" arrWord(44) = "刅chuang" arrWord(45) = "吹chui" arrWord(46) = "旾chun" arrWord(47) = "踔chuo" arrWord(48) = "呲ci" arrWord(49) = "从cong" arrWord(50) = "凑cou" arrWord(51) = "粗cu" arrWord(52) = "汆cuan" arrWord(53) = "崔cui" arrWord(54) = "邨cun" arrWord(55) = "搓cuo" arrWord(56) = "咑da" arrWord(57) = "呆dai" arrWord(58) = "丹dan" arrWord(59) = "当dang" arrWord(60) = "刀dao" arrWord(61) = "恴de" arrWord(62) = "灯deng"arrWord(64) = "敁dian" arrWord(65) = "刁diao" arrWord(66) = "爹die" arrWord(67) = "丁ding" arrWord(68) = "丟diu" arrWord(69) = "东dong" arrWord(70) = "剅dou" arrWord(71) = "嘟du" arrWord(72) = "耑duan" arrWord(73) = "垖dui" arrWord(74) = "吨dun" arrWord(75) = "多duo" arrWord(76) = "妸e" arrWord(77) = "奀en" arrWord(78) = "儿er" arrWord(79) = "发fa" arrWord(80) = "帆fan" arrWord(81) = "方fang" arrWord(82) = "飞fei" arrWord(83) = "分fen" arrWord(84) = "丰feng" arrWord(85) = "仏fo" arrWord(86) = "紑fou" arrWord(87) = "夫fu" arrWord(88) = "旮ga" arrWord(89) = "该gai" arrWord(90) = "干gan" arrWord(91) = "冈gang"arrWord(93) = "戈ge" arrWord(94) = "给gei" arrWord(95) = "根gen" arrWord(96) = "更geng" arrWord(97) = "工gong" arrWord(98) = "勾gou" arrWord(99) = "估gu" arrWord(100) = "瓜gua" arrWord(101) = "乖guai" arrWord(102) = "关guan" arrWord(103) = "光guang" arrWord(104) = "归gui" arrWord(105) = "衮gun" arrWord(106) = "呙guo" arrWord(107) = "铪ha" arrWord(108) = "嗨hai" arrWord(109) = "佄han" arrWord(110) = "夯hang" arrWord(111) = "蒿hao" arrWord(112) = "诃he" arrWord(113) = "黒hei" arrWord(114) = "拫hen" arrWord(115) = "亨heng" arrWord(116) = "叿hong" arrWord(117) = "侯hou" arrWord(118) = "乎hu" arrWord(119) = "花hua" arrWord(120) = "怀huai" arrWord(121) = "欢huan"arrWord(123) = "灰hui" arrWord(124) = "昏hun" arrWord(125) = "吙huo" arrWord(126) = "丌ji" arrWord(127) = "加jia" arrWord(128) = "戋jian" arrWord(129) = "江jiang" arrWord(130) = "艽jiao" arrWord(131) = "阶jie" arrWord(132) = "巾jin" arrWord(133) = "坕jing" arrWord(134) = "冂jiong" arrWord(135) = "丩jiu" arrWord(136) = "凥ju" arrWord(137) = "姢juan" arrWord(138) = "噘jue" arrWord(139) = "军jun" arrWord(140) = "咔ka" arrWord(141) = "开kai" arrWord(142) = "刊kan" arrWord(143) = "忼kang" arrWord(144) = "*kao" arrWord(145) = "匼ke" arrWord(146) = "肎ken" arrWord(147) = "劥keng" arrWord(148) = "空kong" arrWord(149) = "抠kou" arrWord(150) = "郀ku" arrWord(151) = "夸kua"arrWord(153) = "宽kuan" arrWord(154) = "匡kuang" arrWord(155) = "亏kui" arrWord(156) = "坤kun" arrWord(157) = "扩kuo" arrWord(158) = "垃la" arrWord(159) = "来lai" arrWord(160) = "兰lan" arrWord(161) = "啷lang" arrWord(162) = "捞lao" arrWord(163) = "仂le" arrWord(164) = "雷lei" arrWord(165) = "塄leng" arrWord(166) = "唎li" arrWord(167) = "俩lia" arrWord(168) = "嫾lian" arrWord(169) = "簗liang" arrWord(170) = "蹽liao" arrWord(171) = "咧lie" arrWord(172) = "邻lin" arrWord(173) = "伶ling" arrWord(174) = "溜liu" arrWord(175) = "囖lo" arrWord(176) = "龙long" arrWord(177) = "娄lou" arrWord(178) = "露lu" arrWord(179) = "驴lv" arrWord(180) = "孪luan" arrWord(181) = "掠lue"arrWord(183) = "頱luo" arrWord(184) = "妈ma" arrWord(185) = "埋mai" arrWord(186) = "颟man" arrWord(187) = "牤mang" arrWord(188) = "猫mao" arrWord(189) = "庅me" arrWord(190) = "沒mei" arrWord(191) = "椚men" arrWord(192) = "掹meng" arrWord(193) = "咪mi" arrWord(194) = "芇mian" arrWord(195) = "喵miao" arrWord(196) = "乜mie" arrWord(197) = "民min" arrWord(198) = "名ming" arrWord(199) = "谬miu" arrWord(200) = "摸mo" arrWord(201) = "哞mou" arrWord(202) = "母mu" arrWord(203) = "拏na" arrWord(204) = "腉nai" arrWord(205) = "囡nan" arrWord(206) = "囔nang" arrWord(207) = "孬nao" arrWord(208) = "讷ne" arrWord(209) = "馁nei" arrWord(210) = "嫩nen" arrWord(211) = "能neng"arrWord(213) = "拈nian" arrWord(214) = "娘niang" arrWord(215) = "鸟niao" arrWord(216) = "捏nie" arrWord(217) = "脌nin" arrWord(218) = "宁ning" arrWord(219) = "妞niu" arrWord(220) = "农nong" arrWord(221) = "奴nu" arrWord(222) = "女nv" arrWord(223) = "疟nue" arrWord(224) = "奻nuan" arrWord(225) = "郍nuo" arrWord(226) = "噢o" arrWord(227) = "讴ou" arrWord(228) = "妑pa" arrWord(229) = "拍pai" arrWord(230) = "眅pan" arrWord(231) = "乓pang" arrWord(232) = "抛pao" arrWord(233) = "呸pei" arrWord(234) = "喷pen" arrWord(235) = "匉peng" arrWord(236) = "丕pi" arrWord(237) = "片pian" arrWord(238) = "剽piao" arrWord(239) = "氕pie" arrWord(240) = "姘pin" arrWord(241) = "娉ping"arrWord(243) = "仆pu" arrWord(244) = "七qi" arrWord(245) = "掐qia" arrWord(246) = "千qian" arrWord(247) = "呛qiang" arrWord(248) = "悄qiao" arrWord(249) = "切qie" arrWord(250) = "亲qin" arrWord(251) = "靑qing" arrWord(252) = "宆qiong" arrWord(253) = "丘qiu" arrWord(254) = "区qu" arrWord(255) = "峑quan" arrWord(256) = "炔que" arrWord(257) = "夋qun" arrWord(258) = "呥ran" arrWord(259) = "穣rang" arrWord(260) = "荛rao" arrWord(261) = "惹re" arrWord(262) = "人ren" arrWord(263) = "扔reng" arrWord(264) = "日ri" arrWord(265) = "戎rong" arrWord(266) = "厹rou" arrWord(267) = "嶿ru" arrWord(268) = "堧ruan" arrWord(269) = "桵rui" arrWord(270) = "闰run" arrWord(271) = "叒ruo"arrWord(272) = "仨sa" arrWord(273) = "毢sai" arrWord(274) = "三san" arrWord(275) = "桒sang" arrWord(276) = "掻sao" arrWord(277) = "色se" arrWord(278) = "森sen" arrWord(279) = "僧seng" arrWord(280) = "杀sha" arrWord(281) = "筛shai" arrWord(282) = "山shan" arrWord(283) = "伤shang" arrWord(284) = "弰shao" arrWord(285) = "奢she" arrWord(286) = "申shen" arrWord(287) = "升sheng" arrWord(288) = "尸shi" arrWord(289) = "収shou" arrWord(290) = "书shu" arrWord(291) = "刷shua" arrWord(292) = "衰shuai" arrWord(293) = "闩shuan" arrWord(294) = "霜shuang" arrWord(295) = "谁shui" arrWord(296) = "吮shun" arrWord(297) = "说shuo" arrWord(298) = "厶si" arrWord(299) = "忪song" arrWord(300) = "凁sou" arrWord(301) = "苏su"arrWord(303) = "夊sui" arrWord(304) = "孙sun" arrWord(305) = "唆suo" arrWord(306) = "他ta" arrWord(307) = "囼tai" arrWord(308) = "坍tan" arrWord(309) = "汤tang" arrWord(310) = "仐tao" arrWord(311) = "忑te" arrWord(312) = "鼟teng" arrWord(313) = "剔ti" arrWord(314) = "天tian" arrWord(315) = "旫tiao" arrWord(316) = "贴tie" arrWord(317) = "厅ting" arrWord(318) = "囲tong" arrWord(319) = "偷tou" arrWord(320) = "凸tu" arrWord(321) = "湍tuan" arrWord(322) = "推tui" arrWord(323) = "吞tun" arrWord(324) = "乇tuo" arrWord(325) = "屲wa" arrWord(326) = "歪wai"arrWord(327) = "弯wan" arrWord(328) = "尩wang" arrWord(329) = "危wei" arrWord(330) = "昷wen"arrWord(332) = "挝wo" arrWord(333) = "乌wu" arrWord(334) = "夕xi" arrWord(335) = "呷xia" arrWord(336) = "仙xian" arrWord(337) = "乡xiang" arrWord(338) = "灱xiao" arrWord(339) = "些xie" arrWord(340) = "心xin" arrWord(341) = "兴xing" arrWord(342) = "凶xiong" arrWord(343) = "休xiu" arrWord(344) = "戌xu" arrWord(345) = "吅xuan" arrWord(346) = "疶xue" arrWord(347) = "坃xun" arrWord(348) = "丫ya" arrWord(349) = "咽yan" arrWord(350) = "殃yang" arrWord(351) = "邀yao" arrWord(352) = "椰ye" arrWord(353) = "一yi" arrWord(354) = "乚yin" arrWord(355) = "应ying" arrWord(356) = "哟yo" arrWord(357) = "佣yong" arrWord(358) = "优you" arrWord(359) = "扜yu" arrWord(360) = "囦yuan"arrWord(362) = "蒀yun" arrWord(363) = "帀za" arrWord(364) = "災zai" arrWord(365) = "兂zan" arrWord(366) = "牂zang" arrWord(367) = "傮zao" arrWord(368) = "啫ze" arrWord(369) = "贼zei" arrWord(370) = "怎zen" arrWord(371) = "曽zeng" arrWord(372) = "吒zha" arrWord(373) = "夈zhai" arrWord(374) = "沾zhan" arrWord(375) = "张zhang" arrWord(376) = "佋zhao" arrWord(377) = "蜇zhe" arrWord(378) = "贞zhen" arrWord(379) = "凧zheng" arrWord(380) = "之zhi" arrWord(381) = "中zhong" arrWord(382) = "州zhou" arrWord(383) = "朱zhu" arrWord(384) = "抓zhua" arrWord(385) = "拽zhuai" arrWord(386) = "专zhuan" arrWord(387) = "妆zhuang" arrWord(388) = "隹zhui" arrWord(389) = "宒zhun" arrWord(390) = "卓zhuo"arrWord(392) = "宗zong"arrWord(393) = "邹zou"arrWord(394) = "租zu"arrWord(395) = "劗zuan"arrWord(396) = "厜zui"arrWord(397) = "尊zun"arrWord(398) = "昨zuo"arrWord(399) = "咗zuo"For i = 1 To Len(expression)STR = Mid(expression, i, 1)If (Asc(STR) < 0) ThenFor j = 1 To 399If Left(arrWord(j), 1) > STR ThenIf limit = -1 ThenSTR = Mid(arrWord(j - 1), 2) & delimiterElseSTR = Mid(arrWord(j - 1), 2, limit) & delimiterEnd IfExit ForEnd IfNextEnd IfHZQP = HZQP + STRNextHZQP = Left(HZQP, Len(HZQP) - Len(delimiter))End Function在你的excel中创建宏,输入以下内容,然后在excel中使用自定义函数=hsqp(字符表达式,"",开关参数)三种用法: =hzqp(A2,"",-1) =hzqp(A2,"-",-1) =hzqp(A2," ",-1)单词公式拼音公式我们 women women wo-men wo men=hzqp(A2,"",-1) =hzqp(A2,"-",-1) =hzqp(A2," ",-1)三种用法: =hzqp(A2,"",-1) =hzqp(A2,"-",-1) =hzqp(A2," ",-1)。
vba中文转拼音首字母
vba中文转拼音首字母Function getpychar(char)tmp = 65536 + Asc(char)If (tmp >= 45217 And tmp <= 45252) Thengetpychar = "A"ElseIf (tmp >= 45253 And tmp <= 45760) Thengetpychar = "B"ElseIf (tmp >= 45761 And tmp <= 46317) Thengetpychar = "C"ElseIf (tmp >= 46318 And tmp <= 46825) Thengetpychar = "D"ElseIf (tmp >= 46826 And tmp <= 47009) Thengetpychar = "E"ElseIf (tmp >= 47010 And tmp <= 47296) Thengetpychar = "F"ElseIf (tmp >= 47297 And tmp <= 47613) Thengetpychar = "G"ElseIf (tmp >= 47614 And tmp <= 48118) Thengetpychar = "H"ElseIf (tmp >= 48119 And tmp <= 49061) Thengetpychar = "J"ElseIf (tmp >= 49062 And tmp <= 49323) Thengetpychar = "K"ElseIf (tmp >= 49324 And tmp <= 49895) Thengetpychar = "L"ElseIf (tmp >= 49896 And tmp <= 50370) Thengetpychar = "M"ElseIf (tmp >= 50371 And tmp <= 50613) Thengetpychar = "N"ElseIf (tmp >= 50614 And tmp <= 50621) Thengetpychar = "O"ElseIf (tmp >= 50622 And tmp <= 50905) Thengetpychar = "P"ElseIf (tmp >= 50906 And tmp <= 51386) Thengetpychar = "Q"ElseIf (tmp >= 51387 And tmp <= 51445) Thengetpychar = "R"ElseIf (tmp >= 51446 And tmp <= 52217) Thengetpychar = "S"ElseIf (tmp >= 52218 And tmp <= 52697) Thengetpychar = "T"ElseIf (tmp >= 52698 And tmp <= 52979) Thengetpychar = "W"ElseIf (tmp >= 52980 And tmp <= 53640) Thengetpychar = "X"ElseIf (tmp >= 53689 And tmp <= 54480) Thengetpychar = "Y"ElseIf (tmp >= 54481 And tmp <= 62289) Thengetpychar = "Z"Else '如果不是中文,则不处理getpychar = charEnd IfEnd FunctionFunction getpy(str)For i = 1 To Len(str)getpy = getpy & getpychar(Mid(str, i, 1))Next iEnd Function转自天天影院 免费\电影天天在线观看。
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_汉字转换成拼音简拼(只取首字母)名称转换为首字母(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结束。
excel批量将汉字变成拼音的设置方法
excel批量将汉字变成拼音的设置方法要在 Excel 中批量将汉字变成拼音,可以使用以下步骤:1. 打开 Excel 表格,选择要将这些汉字变成拼音的单元格范围。
2. 在 Excel 中打开“拼音指南”选项卡,然后选择“拼音指南”工具栏。
3. 在“拼音指南”工具栏中,点击“添加拼音”按钮,然后在弹出的对话框中选择要应用的拼音方案。
4. 在“拼音指南”工具栏中,选择要应用的拼音方案,然后单击“添加”按钮。
5. 选择要将这些拼音应用到的单元格,然后单击“确定”按钮。
6. 使用 Excel 的“条件格式”工具栏,选择要自动添加拼音的单元格范围。
7. 在“条件格式”工具栏中,选择“突出显示单元格规则”选项卡,然后选择“拼音”。
8. 在“条件格式”工具栏中,选择“格式刷”按钮,然后将拼音格式应用到整个单元格范围。
9. 使用 Excel 的“数据验证”工具栏,选择要将这些拼音应用于的单元格范围。
10. 在“数据验证”工具栏中,选择“限制”选项卡,然后选择“拼音”。
11. 在“数据验证”工具栏中,选择“格式”选项卡,然后选择“拼音格式”,并根据需要设置拼音格式。
12. 使用 Excel 的“自动填充”工具栏,选择要将这些拼音自动应用到的单元格范围。
13. 在“自动填充”工具栏中,选择“从下拉列表中选择”按钮,然后在弹出的对话框中选择“拼音”。
14. 在“自动填充”工具栏中,选择“继续”按钮,然后按照需要重复执行此过程,直到将所有汉字变成拼音。
以上是在 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-VBA单词的首字母大小写转换
Excel-VBA单词的首字母大小写转换应用场景任意对选择区域的字母大小写进行转换知识要点1:StrConv 函数返回按指定类型转换的 Variant (String)。
2:首先通过 Application.InputBox 输入转换方式3:在已选区域中转换Sub 批量大小写转换()Dim Rng As Range, types As ByteOn Error Resume NextIf TypeName(Selection) <> 'Range' Then MsgBox '请选择单元格区域', 64, '提示': Exit Sub'弹出对话框让用户选择转换方式,分别用,1 2 3 来执行不同的转换types = Application.InputBox('输入1:全部大写' & Chr(10) & '输入2:全部小写' & Chr(10) & '输入3:首字母大写', '转换方式', , , , , , 1)If Err <> 0 Then Exit Sub '如果有错误(输入值超过byte的有限范围)则退出If types <> 1 And types <> 2 And types <> 3 Then Exit Sub '如果输入的值不是1 2 3 则退出Application.ScreenUpdating = FalseFor Each Rng In Intersect(edRange, Selection) 'strconv函数,返回按指定类型转换variant,strconv(string,conversion,lcin),conversion = 1 将字符文字转换成大写,=2,转换成小写,=3,字母开通转换为大写Rng = StrConv(Rng, types) '根据输入的数值将单元格按对应的方式进行转换Next RngApplication.ScreenUpdating = True '恢复屏幕更新End Sub。
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*******************************************************************************。
汉字转拼音的解决方案(转帖)VBA实例教程
汉字转拼音的解决方案(转帖)VBA实例教程除非注明,文章均为战战如疯原创,转载请保留链接: /cat4/559.html,VBA交流群273624828。
之前我分享过一个取汉字拼音首字母的函数,利用的是查字库的方法,但是最近使用时发现字库中的错误太多,导致其实用性大打折扣,在网上又查到了一种比较好的解决方案来跟网友分享下。
该方案是Excelhome网友的作品,原帖地址,要求电脑上安装有微软拼音,该自定义函数功能强大,不仅可以用来取首字母,更可以用来显示全部拼音,甚至可以带声调。
请首先确认安装了微软拼音输入法,如果出现注音错误的情况,可尝试安装最新版本微软拼音解决。
[12.01.29]更新解决看柳絮飘扬提出的bug,全部都是非汉字情况不会再显示#Value,同时非中文字符间也不再插入分隔符。
[11.09.29]更新根据dul版的分析,加入了运行环境检查,没有运行环境的话会提示安装微软拼音。
[11.09.23]更新4年来不断有人问多音字的问题,这次更新终于解决了,由于写了这个函数之后我就从来没用到过,遇到些问题就放下了,一拖就这么久,要不是不断有人给我发消息可能就不会再有这次的更新了,还要感谢大家的使用和督促,让各位久等了。
更新后,“重庆重要”能够正确解析为“chóng qìng zhòng yào” 。
这次重写了很多代码,没有过多测试不知道有没有bug,发现bug的同学请给我发消息,谢谢。
代码在32位Win7 + Office2010和WinXp + office2010测试通过,64位的系统应该会出错,就不要测试了。
以前遇到过2010下写的VBA代码在之前版本运行会报未找到库之类的错误,代码中注意了,但仍可能会有遗漏,总之,请大家反馈意见,让这个小函数更好的为大家服务。
'************************************************************** *************'*'* Module: HzToPy'* Update: 2011-09-23'* Author: tt.t'*'* Description: 将中文字符串转换为拼音,就这些。
excel函数:实现将中文姓名转化拼音,并只取首字母
Function PinYin(Hz As String)
Dim PinMa As String
Dim MyPinMa As Variant
Dim Temp As Integer, i As Integer, j As Integer
PinMa = PinMa & "ka,16474,kai,16470,kan,16465,kang,16459,kao,16452,ke,16448,ken,16433,keng,16429,kong,16427,kou,16423,ku,16419,kua,16412,kuai,16407,kuan,16403,kuang,16401,kui,16393,kun,16220,kuo,16216,"
PinMa = PinMa & "na,15165,nai,15158,nan,15153,nang,15150,nao,15149,ne,15144,nei,15143,nen,15141,neng,15140,ni,15139,nian,15128,niang,15121,niao,15119,nie,15117,nin,15110,ning,15109,niu,14941,nong,14937,nu,14933,nv,14930,nuan,14929,nue,14928,nuo,14926,"
PinMa = PinMa & "qi,14630,qia,14594,qian,14429,qiang,14407,qiao,14399,qie,14384,qin,14379,qing,14368,qiong,14355,qiu,14353,qu,14345,quan,14170,que,14159,qun,14151,"
如何使用Excel将中文名转换成拼音
方法一:自定义函数法1.创建一个Excel文件2.打开Excel,点击“文件-选项”。
如下图:3.将“开发工具”调出。
如下图:4.点击“开发工具- Visual Basic”。
如下图:5.右击插入模块,复制代码(在文末)。
如下图:6.保存时候会出来这个选项,都可以,不影响后续。
如下图:7.像普通函数一样,使用即可。
代码:Function pinyin(p As String) As String i = 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 -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 -19725 To -19716: pinyin = "chan " 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 -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 -18448 To -18448: pinyin = "fo " 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 -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 -16983 To -16971: pinyin = "jiang " 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 -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 -15903 To -15890: pinyin = "ling " 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 -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 -15109 To -14942: pinyin = "ning " 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 -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 -14135 To -14126: pinyin = "ren " 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 -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 -13318 To -13148: pinyin = "ta " 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 -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 -11798 To -11782: pinyin = "yang " 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 -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 -10270 To -10263: pinyin = "zu "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 FunctionFunction gets(str) '得到首字母gets = Left(getpy(str), 1)End FunctionFunction getqs(str) '得到全首字母For i = 1 To Len(str)getqs = getqs & Left(pinyin(Mid(str, i, 1)), 1) Next iEnd Function。
excel汉字转全拼音函数
excel汉字转全拼音函数
Excel汉字转全拼音函数
在日常工作中,我们常常会遇到需要将汉字转换为拼音的情况。
例如,在处理数据时,将中文名称转换为拼音可以方便排序和查询。
为了解决这个问题,我们可以在Excel中使用自定义函数来实现汉字转全拼音的功能。
步骤1:创建一个新的模块
首先,打开Excel并创建一个新的工作簿。
然后,按下Alt + F11打开Visual Basic for Applications(VBA)编辑器。
在VBA编辑器中,选择插入>模块,创建一个新的模块。
步骤2:编写函数代码
在新创建的模块中,我们可以编写函数代码来实现汉字转全拼音的功能。
以下是一个简单的示例函数:
```vba
Function HanziToPinyin(str As String) As String
Dim i As Long
Dim chineseChar As String
Dim pinyin As String
For i = 1 To Len(str)
chineseChar = Mid(str, i, 1)
' 如果是汉字,则转换为拼音
If Asc(chineseChar) >= 19968 And Asc(chineseChar) <= 40869 Then
pinyin = pinyin &
Application.WorksheetFunction.VLookup(chineseChar, Range(\。
在Excel中获取汉字拼音首字母并大写
在Excel中获取汉字拼⾳⾸字母并⼤写最终效果如果单元格输⼊=getpychar(E2),并下拉填充,获取的是⼤写⾸字母1. 打开【开发⼯具】菜单,点击第⼀个【VisualBasic】,弹出代码窗⼝,在窗⼝左侧空⽩处,点击右键,选择【插⼊】->【模块】。
窗⼝右侧出现⼀个⽩⾊背景框。
2. 复制粘贴如下代码内容到编辑框中,并保存Function getpychar(char)tmp = 65536 + Asc(char)If (tmp >= 45217 And tmp <= 45252) Thengetpychar = "A"ElseIf (tmp >= 45253 And tmp <= 45760) Thengetpychar = "B"ElseIf (tmp >= 45761 And tmp <= 46317) Thengetpychar = "C"ElseIf (tmp >= 46318 And tmp <= 46825) Thengetpychar = "D"ElseIf (tmp >= 46826 And tmp <= 47009) Thengetpychar = "E"ElseIf (tmp >= 47010 And tmp <= 47296) Thengetpychar = "F"ElseIf (tmp >= 47297 And tmp <= 47613) Thengetpychar = "G"ElseIf (tmp >= 47614 And tmp <= 48118) Thengetpychar = "H"ElseIf (tmp >= 48119 And tmp <= 49061) Then getpychar = "J"ElseIf (tmp >= 49062 And tmp <= 49323) Then getpychar = "K"ElseIf (tmp >= 49324 And tmp <= 49895) Then getpychar = "L"ElseIf (tmp >= 49896 And tmp <= 50370) Then getpychar = "M"ElseIf (tmp >= 50371 And tmp <= 50613) Then getpychar = "N"ElseIf (tmp >= 50614 And tmp <= 50621) Then getpychar = "O"ElseIf (tmp >= 50622 And tmp <= 50905) Then getpychar = "P"ElseIf (tmp >= 50906 And tmp <= 51386) Then getpychar = "Q"ElseIf (tmp >= 51387 And tmp <= 51445) Then getpychar = "R"ElseIf (tmp >= 51446 And tmp <= 52217) Then getpychar = "S"ElseIf (tmp >= 52218 And tmp <= 52697) Then getpychar = "T"ElseIf (tmp >= 52698 And tmp <= 52979) Then getpychar = "W"ElseIf (tmp >= 52980 And tmp <= 53640) Then getpychar = "X"ElseIf (tmp >= 53679 And tmp <= 54480) Then getpychar = "Y"ElseIf (tmp >= 54481 And tmp <= 62289) Then getpychar = "Z"Else '如果不是中⽂,则不处理getpychar = chargetpychar = charEnd IfEnd Function'逐个取ASC码Function getpy(str)For i = 1 To Len(str)getpy = getpy & getpychar(Mid(str, i, 1))Next iEnd Function3. 点击菜单中【保存】,弹出⼀个提⽰框,点【是】,再次弹出⼀个提⽰框,点【确定】。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Case -18211 To -18202: pinyin ="Gao "
Case -18201 To -18185: pinyin ="Ge "
Case -18184 To -18184: pinyin ="Gei "
Case -19739 To -19729: pinyin ="Cha "
Case -19728 To -19726: pinyin ="Chai "
Case -19725 To -19716: pinyin ="Chan "
Case -19715 To -19541: pinyin ="Chang "
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 -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 -19270 To -19264: pinyin ="Chun "
Case -19263 To -19262: pinyin ="Chuo "
Case -19261 To -19250: pinyin ="Ci "
Case -19249 To -19244: pinyin ="Cong "
Case -16647 To -16475: pinyin ="Jun "
Case -16474 To -16471: pinyin ="Ka "
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 -17454 To -17434: pinyin ="Hui "
Case -17433 To -17428: pinyin ="Hun "
Case -17427 To -17418: pinyin ="Huo "
Case -17417 To -17203: pinyin ="Ji "
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 -17202 To -17186: pinyin ="Jia "
Case -17185 To -16984: pinyin ="Jian "
Case -16983 To -16971: pinyin ="Jiang "
Case -16970 To -16943: pinyin ="Jiao "
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 -18183 To -18182: pinyin ="Gen "
Case -18181 To -18013: pinyin = pinyin ="Gong "
Case -17997 To -17989: pinyin ="Gou "
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 -19756 To -19752: pinyin ="Cang "
Case -19751 To -19747: pinyin ="Cao "
Case -19746 To -19742: pinyin ="Ce "
Case -19741 To -19740: pinyin ="Ceng "
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 -19038 To -19024: pinyin ="Dan "
Case -19023 To -19019: pinyin ="Dang "
Case -19018 To -19007: pinyin ="Dao "
Case -19006 To -19004: pinyin ="De "
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 -19990 To -19987: pinyin ="Biao "
Case -19986 To -19983: pinyin ="Bie "
Case -19982 To -19977: pinyin ="Bin "
Case -19976 To -19806: pinyin ="Bing "
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 -19003 To -18997: pinyin ="Deng "
Case -18996 To -18978: pinyin ="Di "
Case -18977 To -18962: pinyin ="Dian "
Case -18961 To -18953: pinyin ="Diao "
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 -19227 To -19225: pinyin ="Cun "
Case -19224 To -19219: pinyin ="Cuo "