构建一个宏,使用电子表格本身的信息向多家公司发送电子邮件。我通过将名称粘贴到单独的表格中然后检查列中的公司名称和员工姓名来跟踪已经通过电子邮件发送的公司。我好像在做些傻事。我以为我可以使用数组来完成相同的任务,但是你能搜索到数组的全部内容吗?此外,公司数量因日而异。
以下代码
firmName = reportsByFirm.Cells(row_num, firmcol)
empName = reportsByFirm.Cells(row_num, traderCol)
continue = True
empSeparate = False
emrow_num = 3
firmAlreadyRun = emailMaster.Columns(26).Find(What:=firmName).Address
empAlreadyRun = emailMaster.Columns(27).Find(What:=traderName).Address
If firmAlreadyRun <> Empty Then
GoTo Skip
ElseIf empAlreadyRun <> Empty Then
GoTo Skip
End If
答案 0 :(得分:1)
Dim firmAlreadyRun As Range, empAlreadyRun As Range
firmName = reportsByFirm.Cells(row_num, firmcol)
empName = reportsByFirm.Cells(row_num, traderCol)
continue = True
empSeparate = False
emrow_num = 3
Set firmAlreadyRun = emailMaster.Columns(26).Find(What:=firmName, LookAt:=xlWhole)
Set empAlreadyRun = emailMaster.Columns(27).Find(What:=traderName, LookAt:=xlWhole)
If Not firmAlreadyRun Is Nothing Or Not empAlreadyRun Is Nothing Then
GoTo Skip
End If