it can just be one emailit should send entire spreadsheet to everyone listed in column N in one email or in a seperate emails?
Sub test()
Dim lastRow As Long
Dim recipients As String
Dim WB As Workbook
Dim oApp As Object, oMail As Object
Application.ScreenUpdating = False
With ActiveSheet
lastRow = .Cells(.Rows.Count, "n").End(xlUp).Row
For i = 2 To lastRow
recipients = ";" & .Range("n" & i).Value
Next i
End With
Set WB = ActiveWorkbook
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.CreateItem(0)
With oMail
.to = recipients
.Subject = "test subject"
.HTMLBody = "test body" & .HTMLBody
.Attachments.Add WB.FullName
.Display
End With
Set oMail = Nothing
Set oApp = Nothing
Application.ScreenUpdating = True
End Sub
Sub MM1()
Dim lastRow As Long, recipients As String, WB As Workbook
Dim oApp As Object, oMail As Object, i As Long, filename As String
ActiveSheet.Copy
Set WB = ActiveWorkbook
filename = WB.Worksheets(1).Name
On Error Resume Next
Kill "C:\temp\" & filename
On Error GoTo 0
WB.SaveAs filename:="C:\temp\" & filename
Application.ScreenUpdating = False
With ActiveSheet
lastRow = .Cells(.Rows.Count, "n").End(xlUp).Row
For i = 2 To lastRow
recipients = recipients & ";" & .Range("n" & i).Value
Next i
End With
Set WB = ActiveWorkbook
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.CreateItem(0)
With oMail
.To = recipients
.Subject = "test subject"
.HTMLBody = "test body" & .HTMLBody
.Attachments.Add WB.FullName
.Display
End With
Set oMail = Nothing
Set oApp = Nothing
Application.ScreenUpdating = True
End Sub
that works! thanks so much!!!Try this
VBA Code:Sub MM1() Dim lastRow As Long, recipients As String, WB As Workbook Dim oApp As Object, oMail As Object, i As Long, filename As String ActiveSheet.Copy Set WB = ActiveWorkbook filename = WB.Worksheets(1).Name On Error Resume Next Kill "C:\temp\" & filename On Error GoTo 0 WB.SaveAs filename:="C:\temp\" & filename Application.ScreenUpdating = False With ActiveSheet lastRow = .Cells(.Rows.Count, "n").End(xlUp).Row For i = 2 To lastRow recipients = recipients & ";" & .Range("n" & i).Value Next i End With Set WB = ActiveWorkbook Set oApp = CreateObject("Outlook.Application") Set oMail = oApp.CreateItem(0) With oMail .To = recipients .Subject = "test subject" .HTMLBody = "test body" & .HTMLBody .Attachments.Add WB.FullName .Display End With Set oMail = Nothing Set oApp = Nothing Application.ScreenUpdating = True End Sub