目前我正在处理数据库 Excel 电子表格,我目前正在使用 VBA 来实现系统的一些自动功能。我是 VBA 新手,所以我需要你的帮助 :)
我的问题是:我有一个雕像列,用户需要从下拉列表中选择“完成”或“进行中”。我需要一个可以扫描特定列(例如 S3)以查找“完成”一词的程序。一旦检测到这个词,系统会自动向特定用户发送一封电子邮件,告诉他任务已经完成。
谁能帮我?
谢谢!:)
更新:我编写了以下代码来搜索完整的单词并向用户发送电子邮件(这是一个粗略的想法)
Sub For_Loop_With_Step()
Dim lCount As Long, lNum As Long
Dim MyCount As Long
MyCount = Application.CountA(Range("S:S"))
For lCount = 1 To MyCount - 1 Step 1
If Cells(lCount + 2, 19) = "Complete" Then
Call Send_Email_Using_VBA
Else
MsgBox "Nothing found"
End If
Next lCount
MsgBox "The For loop made " & lNum & " loop(s). lNum is equal to " & lNum
End Sub
.
Sub Send_Email_Using_VBA()
Dim Email_Subject, Email_Send_From, Email_Send_To, _
Email_Cc, Email_Bcc, Email_Body As String
Dim Mail_Object, Mail_Single As Variant
Email_Subject = "Testing Results"
Email_Send_From = "fromperson@example.com"
Email_Send_To = "toperson@example.com"
'Email_Cc = "someone@example.com"
'Email_Bcc = "someoneelse@example.com"
Email_Body = "Congratulations!!!! You have successfully sent an e-mail using VBA !!!!"
On Error GoTo debugs
Set Mail_Object = CreateObject("Outlook.Application")
Set Mail_Single = Mail_Object.CreateItem(0)
With Mail_Single
.Subject = Email_Subject
.To = Email_Send_To
.cc = Email_Cc
.BCC = Email_Bcc
.Body = Email_Body
.send
End With
debugs:
If Err.Description <> "" Then MsgBox Err.Description
End Sub