美文网首页
【效率工具】提取excel单元格中随机位置出现的连续的6位数字

【效率工具】提取excel单元格中随机位置出现的连续的6位数字

作者: 南山寒鸦 | 来源:发表于2020-06-30 22:25 被阅读0次

1.文档保存为启用宏的工作簿
2.然后打开工作i簿,ALT+F11组合键打开VBA编辑窗口,点击 菜单栏--插入--模块,复制代码到新建模块的代码编辑区
3.保存,返回工作表,和使用其他函数一样,输入:=sfind(N23)

Option Explicit
 Function sfind(ByVal str As Variant)
    Dim mc As Variant
    With CreateObject("vbscript.regexp")
        .Global = False
        .Pattern = "[0-9]{6}"
        If Not .test(str) Then
        sfind = "null": Exit Function
        End If
        Set mc = .Execute(str)
    End With
    sfind = mc.Item(0)
    Set mc = Nothing
End Function"

参考链接:https://zhidao.baidu.com/question/1950611345817243908.html

相关文章

网友评论

      本文标题:【效率工具】提取excel单元格中随机位置出现的连续的6位数字

      本文链接:https://www.haomeiwen.com/subject/pdifqktx.html