EXCEL小工具备忘
汉字转拼音首字母
点击:“工具→宏→Visual Basic编辑器”命令(或者直接按“Alt+F11”组合键) 执行“插入→模块”命令,插入一个新模块。 将代码输入其中
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编辑状态,自定义函数getpy就可以使用了,配合以下函数: 转换为小写:=LOWER(字符串) 转换为大写:=UPPER(字符串) 首字母大写:=PROPER(字符串)
生成随机字符串
准备资源:在excel中输入待随机的内容,记下坐标类似J2到J27
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
0
1
2
3
4
5
6
7
8
9
公式:=CONCAT(INDIRECT(“J”&RANDBETWEEN(2,27),INDIRECT(“J”&RANDBETWEEN(2,27)) 以上就是2个随机数,需要多少就增加多少INDIRECT