我是VBA的新手。我正在努力学习它,但有一点我现在被困住了。如果有人请帮助我,那么我将不胜感激。 我有一个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)
我已经创建了一个单独的行(第59行Col A),其中我将上述行中的这些值组合在一起。
我必须制作一个宏来向这些多人发送1封电子邮件。我已经编写了一个发送电子邮件的代码,但我被困在另一个角落。我编写了代码,只要它在第59行中找到它就用{“替换单词please select
,但不幸的是,代码永久地更改了我不想要的行。
我想要的是,只要它在一行中找到单词please select
,它就会忽略它,并且也不会改变单元格的格式。意味着我再次通过下拉列表更改一些新值,以便更改。
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