zoukankan      html  css  js  c++  java
  • Excel2016通过宏生成拼音码

    • 一:视图---->宏---->录制宏

    • 二:试图---->宏---->查看宏

    • 三:点击编辑,输入如下代码片段,点击保存,并选择是
    Function pinyin(p As String) As String
     
    i = Asc(p)
     
    Select Case i
     
    Case -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 = p
     
    End Select
     
    End Function
     
    Function getpy(str)
     
    For i = 1 To Len(str)
     
    getpy = getpy & pinyin(Mid(str, i, 1))
     
    Next i
     
    End Function

    • 四:回到excel,鼠标定位到“拼音码”列第一行(C2单元格)。在函数框中输入=getpy(B2),(调用自定义函数,获取B2单元格中汉字内容首字母)回车,可以看到获取到B2单元格中内容的首字母

    • 五:鼠标定位到单元格C2右下角,光标变成黑色十字,按住鼠标左键一直往下拉。获取全部内容的拼音码。

  • 相关阅读:
    给数组赋值nan
    loc和iloc的区别
    爬虫26-部署crawl爬虫
    爬虫25-scrapy框架详解
    爬虫24-scrapy框架部署
    爬虫23-验证码识别
    爬虫22-使用selenium爬取信息
    爬虫21-selenium用法
    爬虫20-浏览器自动运行简单方法
    爬虫19-线程生产者和消费者以及队列
  • 原文地址:https://www.cnblogs.com/xiaopotian/p/8079127.html
Copyright © 2011-2022 走看看