急!请问如何在excel表格中设置excel函数公式,使前表=后表内容的中间两个字?
下面是一个VBA自定义函数。
1,打开一个工作表;
2.按ALT+F11(或执行工具-宏- VisualBasic编辑器);
3.执行“Insert-Module”,然后双击新插入的模块,将下面的代码粘贴到右边的窗口中。
4.如果A1的内容是中国航天六号A,在B1中输入=hztopy(A1)即可。
函数hztopy(hzpy作为字符串)作为字符串
Dim hzstring作为字符串,pystring作为字符串
Dim hzpysum为整数,hzi为整数,hzpyhex为整数
hzstring = Trim(hzpy)
hzpysum = Len(Trim(hzstring))
pystring = " "
对于hzi = 1到hzpysum
hzpyhex = " & ampH" +十六进制(Asc(Mid(hzstring,hzi,1)))
选择案例hzpyhex
凯斯& amphb0a 1 To & amp;HB0C4: pystring = pystring + "A "
凯斯& ampHB0C5 To & ampHB2C0: pystring = pystring + "B "
凯斯& amphb2c 1 To & amp;HB4ED: pystring = pystring + "C "
凯斯& ampHB4EE To & ampHB6E9: pystring = pystring + "D "
凯斯& ampHB6EA To & amphb7a 1:py string = py string+" E "
凯斯& ampHB7A2到& ampHB8C0: pystring = pystring + "F "
凯斯& ampHB8C1到& ampHB9FD: pystring = pystring + "G "
凯斯& ampHB9FE To & ampHBBF6: pystring = pystring + "H "
凯斯& ampHBBF7 To & ampHBFA5: pystring = pystring + "J "
凯斯& ampHBFA6 To & ampHC0AB: pystring = pystring + "K "
凯斯& ampHC0AC To & ampHC2E7: pystring = pystring + "L "
凯斯& ampHC2E8 To & ampHC4C2: pystring = pystring + "M "
凯斯& ampHC4C3到& ampHC5B5: pystring = pystring + "N "
凯斯& ampHC5B6 To & ampHC5BD: pystring = pystring + "O "
凯斯& ampHC5BE To & ampHC6D9: pystring = pystring + "P "
凯斯& ampHC6DA To & ampHC8BA: pystring = pystring + "Q "
凯斯& ampHC8BB To & ampHC8F5: pystring = pystring + "R "
凯斯& ampHC8F6到& ampHCBF9: pystring = pystring + "S "
凯斯& ampHCBFA To & ampHCDD9: pystring = pystring + "T "
凯斯& ampHEDC5: pystring = pystring + "T "
凯斯& ampHCDDA To & ampHCEF3: pystring = pystring + "W "
凯斯& ampHCEF4到& ampHD 1b 8:py string = py string+" X "
凯斯& ampHD 1b 9 To & amp;HD4D0: pystring = pystring + "Y "
凯斯& ampHD4D1至& ampHD7F9: pystring = pystring + "Z "
其他情况
pystring = pystring + Mid(hzstring,hzi,1)
结束选择
然后
hztopy = pystring
结束功能