Ricky

链接

RSS

RSS Link
DB2使用正则表达式
选择一天中最大记录

Excel VBA宏中使用正则表达式

Ricky posted @ 2015年6月18日 10:02 in Other , 1567 阅读
 
'定义变量类型
Dim reg As Object
Set reg = CreateObject("vbscript.RegExp")

'定义正则表达式
With reg
    .Global = True
    .Pattern = "^[0-9]{4}$"
End With
'测试是否符合表达式
If Not reg.test(Range("$A$" & i).Value) Then
    Range("$A$" & i).Select
    errMsg = 。。。
    Application.Run "'" & ActiveWorkbook.Name & "'!ExitSub"
End If
 
 
除了test还有其他函数可以调用,比如replace等。

 


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter