当电子邮件格式错误时,将单元格着色为红色

问题描述 投票:-1回答:1

当我的电子邮件有像屏幕截图qazxsw poi那样糟糕的格式时,我的单元格如何变成红色?

http://prntscr.com/ilgbcd
vba excel-vba excel
1个回答
0
投票

我想你的代码调用 Function EmailValide(ByVal strEmail As String) As Boolean Dim re As VBScript_RegExp_55.RegExp ' We create a regular expression Set re = New VBScript_RegExp_55.RegExp ' We define the criteria to respect for an e-mail re.Pattern = "w+([-+.']w+)*@w+([-.]w+)*.w+([-.]w+)*" 'The RegExp.Test function returns True if the email meets the criteria EmailValide = re.Test(strEmail) End Function 会是这样的:

EmailValide()

然后你可以使用:

Dim myCell As Range
...
Set myCell = Range("...") ' set myCell in some way
...
© www.soinside.com 2019 - 2024. All rights reserved.