今天刚开始尝试VBA。创建 Excel 表来跟踪 SOLD、PENDING、LOST,这将允许销售人员单击按钮一次将组电子邮件发送到一个类别。经过大量搜索后,我发现一些代码可以很好地通过检查列来发送群组电子邮件,以确保存在正确的地址。我发现了一些我认为可以检查“作业状态”列的其他代码,以便只选择“已售出”或其他任何内容作为电子邮件。我是一个无知的初学者,需要帮助。这是在我添加 - If Sh.Cells(Target.Row, 7) = "PENDING" Then - 部分之前有效的代码。任何帮助将不胜感激。谢谢!
Private Sub CommandButton1_Click()
Dim cell As Range
Dim strto As String
For Each cell In ThisWorkbook.Sheets("Sales 2013").Range("E3:E500")
If cell.Value Like "?*@?*.?*" Then
If Sh.Cells(Target.Row, 7) = "PENDING" Then
strto = strto & cell.Value & ";"
End If
End If
Next cell
If Len(strto) > 0 Then strto = Left(strto, Len(strto) - 1)
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
On Error GoTo cleanup
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = "Anchor Sales"
.Bcc = strto
.Subject = "Enter subject here"
.Body = "" ' EMPTY FOR NOW
'USE THIS FOR ENTERING NAMES OF RECIPIENTS IN BODY TEXT "here"
'"Dear" & Cells(cell.Row, "A").Value _
& vbNewLine & vbNewLine & _
"Enter body text " & _
"here"
'You can add files also like this
'.Attachments.Add ("C:\test.txt")
'.Send 'Or use Display
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub
Private Sub CommandButton2_Click()
End Sub
请帮忙!