使用VBA插入前匹配Email ID



我有7101个电子邮件id在A1表1。现在我要在Sheet2中插入New Email ID。我要创建一个用户表单,在插入新的电子邮件ID之前,用户应该检查电子邮件ID是否存在于Sheet1中。如果存在电子邮件ID,它会显示一个消息框'该电子邮件已经存在'

我该怎么做?

Dim ws As Worksheet
Set ws = Sheets("Sheet 1")
Dim rg As Range
Set rg = Range("A1", ws.Range("A1").End(xlDown))
Dim emailFound As Range
Set emailFound = rg.Find("foo@bar.com", lookin:=xlValues)
If Not emailFound Is Nothing Then MsgBox "The email is already there" 
[...]

最新更新