搜索
查看: 2304|回复: 0

提取数字提取字符规范格式VBA

[复制链接]

977

主题

1093

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
15934
发表于 2018-12-31 16:50:56 | 显示全部楼层 |阅读模式
Sub 提取数字()
Set regx = CreateObject("vbscript.regexp")
With regx
    .Global = True
    .Pattern = "\D"
    For Each Rng In [a1:a4]
        Cells(Rng.Row, 2) = .Replace(Rng, "")
    Next
End With
End Sub

Sub 提取字符()
Set regx = CreateObject("vbscript.regexp")
With regx
    .Global = True
    .Pattern = "\w"
    For Each Rng In [a1:a4]
        Cells(Rng.Row, 2) = .Replace(Rng, "")
    Next
End With
End Sub


Sub 规范格式()
Set regx = CreateObject("vbscript.regexp")
With regx
    .Global = True
    .Pattern = "\s"
    For Each Rng In [a1:a4]
        Cells(Rng.Row, 2) = .Replace(Rng, "-")
    Next
End With
End Sub


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

表格智创网

网站简介:表格智创网,是一家以表格设计和技能分享的专业社区,由会计帮帮网投资建设,尽专业,助提高专业技能。

表格智创网欢迎您!

联系我们

  • 工作时间:早上9:00-16:00
  • 客服电话:18668755857
  • 本站网址:www.excelwps.com
  • 淘宝店址:kjbbw.taobao.com

Powered by Discuz! X3.4 © 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表