[英]How to ignore specific word from a group of words in a cell and send one email to group of people?
I am new to VBA. 我是VBA的新手。 I am working hard and learning it but there is a point where I am stuck now.
我正在努力学习,但是现在有一个问题。 If someone please help me out then I shall be grateful.
如果有人请帮助我,我将不胜感激。 I have a drop down list in excel like
我在excel中有一个下拉列表,例如
Sales/Acquisition Manager (AM) Alina (Alina@yahoo.com)
Acquisition Project Manager (APM) Benny(Benny@yahoo.com)
Manufacturing Julia(Julia@yahoo.com)
Application please select (drop down list so I can choose)
AE external sensor responsible please select (Drop down list so I can choose)
I have made a separate row (row 59 Col A) where I have combined these values from the above rows. 我做了一个单独的行(第59行A列),在这里我合并了以上各行的这些值。
I have to make a macro to send 1 email to these multiple people. 我必须做一个宏才能向这些多人发送1封电子邮件。 I have written a code for sending email but I am stuck at another point.
我已经编写了用于发送电子邮件的代码,但是我被困在其他地方。 I have written code which replaces the words
please select
with “ ” whenever it finds it in row 59 but unfortunately that code changes the line permanently which I don't want. 我写的代码取代了的话
please select
以“”只要找到它排59,但不幸的代码永久改变了线,我不想。
What I want is that whenever it finds the words please select
in a row it just ignores it and and also doesn't change the format of cell. 我想要的是,只要找到单词,
please select
连续please select
它,它只会忽略它,并且不会更改单元格的格式。 Means when I again change some new value by drop down list so it got changed. 表示当我再次通过下拉列表更改一些新值时,它被更改了。
Private Sub CommandButton1_Click()
Dim the_string As String
the_string = Sheets("Schedule_team").Range("A59")
the_string = Replace(the_string, "please select", " ")
Sheets("Schedule_team").Range("A59") = the_string
MsgBox (Sheets("Schedule_team").Range("A59"))
Dim i As Integer, Mail_Object, Email_Subject, o As Variant, lr As Long, x As Variant
Set Mail_Object = CreateObject("Outlook.Application")
x = Cells (59, 1).Value
With Mail_Object.CreateItem(o)
' .Subject = Range("B1").Value
.To = x
' .Body = Range("B2").Value
' .Send
.display 'disable display and enable send to send automatically
End With
MsgBox "E-mail successfully sent", 64
Application.DisplayAlerts = False
Set Mail_Object = Nothing
End Sub
Pull the contents of A59 into the string, replace as needed, then just use that string instead of copying it back to the sheet. 将A59的内容拉入字符串中,根据需要进行替换,然后仅使用该字符串,而不是将其复制回到工作表中。
Untested, just used your code 未经测试,仅使用您的代码
Private Sub CommandButton1_Click()
Dim Mail_Object as Object
Dim the_string As String
the_string = Sheets("Schedule_team").Range("A59")
the_string = Replace(the_string, "please select", " ")
Set Mail_Object = CreateObject("Outlook.Application")
With Mail_Object.CreateItem(o)
' .Subject = Range("B1")
.To = the_string
' .Body = Range("B2")
' .Send
.Display 'disable display and enable send to send automatically
End With
MsgBox "E-mail successfully sent", 64
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.