KFerguson84
New Member
- Joined
- Jan 19, 2016
- Messages
- 4
Hello.
I am trying to get the below code to run to open an email addressed to email addresses that populate in a cell based on a VLOOKUP.
The code is
[Private Sub CommandButton21_Click()Sub SendingSheet()
Dim oMSOutlook As Object
Dim oEmail As Object
Set oMSOutlook = CreateObject("Outlook.Application")
Set oEmail = oMSOutlook.CreateItem(olMailItem)
With oEmail
.To = ActiveSheet.Cells(1, 1)
.CC = ActiveSheet.Cells(2, 1)
.BCC = ActiveSheet.Cells(3, 1)
.Send
End With
Set oMSOutlook = Nothing
Set oEmail = Nothing
End Sub]
When I run it, I get an error that reads:
Compile Error:
Expected End Sub
I am good at Excel but new to Visual Basic. I'm hoping someone can tell me what I am doing to cause the error and point me in the right direction.
Thank you!!!!
I am trying to get the below code to run to open an email addressed to email addresses that populate in a cell based on a VLOOKUP.
The code is
[Private Sub CommandButton21_Click()Sub SendingSheet()
Dim oMSOutlook As Object
Dim oEmail As Object
Set oMSOutlook = CreateObject("Outlook.Application")
Set oEmail = oMSOutlook.CreateItem(olMailItem)
With oEmail
.To = ActiveSheet.Cells(1, 1)
.CC = ActiveSheet.Cells(2, 1)
.BCC = ActiveSheet.Cells(3, 1)
.Send
End With
Set oMSOutlook = Nothing
Set oEmail = Nothing
End Sub]
When I run it, I get an error that reads:
Compile Error:
Expected End Sub
I am good at Excel but new to Visual Basic. I'm hoping someone can tell me what I am doing to cause the error and point me in the right direction.
Thank you!!!!