Patriot2879
Well-known Member
- Joined
- Feb 1, 2018
- Messages
- 1,259
- Office Version
- 2010
- Platform
- Windows
hi i have the below code where i want to add a range to the email address located in sheet (email links) i have done for example the A2:A20 but this doesnt seem to work it only find the email address in A2 and not in A3, A4, A5 etc, please can you help me wioth this? thanks for your help it is really appreciated.
Code:
Private Sub CommandButton4_Click()
Dim aOutlook As Object
Dim aEmail As Object
Dim rngeAddresses As Range, rngeCell As Range, strRecipients As String
Set aOutlook = CreateObject("Outlook.Application")
Set aEmail = aOutlook.CreateItem(0)
aEmail.Body = "Hi There," & Chr(10) & vbCrLf & _
"Appt Number: " & Me.TextBox1.Value & Chr(10) & _
"MPAN / MPRN: " & Me.TextBox2.Value & Chr(10) & _
"Time Slot: " & Me.TextBox3.Value & Chr(10) & _
"PostCode: " & Me.TextBox6.Value & Chr(10) & _
"Status: " & Me.ComboBox1.Value & Chr(10) & _
"Reason: " & Me.ComboBox2.Value & Chr(10) & _
"Additional Notes: " & Me.TextBox7.Value & Chr(10) & vbCrLf & _
"Many thanks " & Chr(10)
aEmail.Recipients.Add (Worksheets("Email Links").Range[B]("A2:A20")[/B].Value)
aEmail.CC = (Worksheets("Email Links").Range[B]("B2:B20")[/B].Value)
aEmail.BCC = ""
aEmail.Subject = "" & UserForm7.ComboBox1.Value & " " & UserForm7.TextBox6.Value & " " & UserForm7.TextBox3.Value & " " & Worksheets("Northants").Range("J1").Value
aEmail.Display
Dim emptyRow As Long
With ThisWorkbook.Sheets("Northants")
emptyRow = Cells(Rows.Count, "A").End(xlUp).Row + 1
.Cells(emptyRow, 1).Value = TextBox1.Value
.Cells(emptyRow, 2).Value = TextBox2.Value
.Cells(emptyRow, 3).Value = TextBox3.Value
.Cells(emptyRow, 6).Value = TextBox6.Value
.Cells(emptyRow, 10).Value = ComboBox1.Value
.Cells(emptyRow, 8).Value = ComboBox2.Value
.Cells(emptyRow, 7).Value = TextBox7.Value
.Cells(emptyRow, 5).Value = ComboBox3.Value
End With
Unload Me
End Sub