I found this code, and can't figure it out

counihan3

Active Member
Joined
Mar 9, 2007
Messages
458
I found this code while do a search on the site. It does exactly what I am looking for. I know that it is a little old, but I think it will still work. My problem is that I am no able to define the mail recpient, everything I have tried so fair has not worked. Can someone tell me how to define s.

Code:
Sub test()
Dim myFile As String, s As String
Dim c 
myFile = Range("B5").Value
ThisWorkbook.ActiveSheet.Copy
'Need to assign name via saveas
ActiveWorkbook.SaveAs "C:\Windows\temp\" & myFile
ThisWorkbook.Activate
If Not IsNull(Application.MailSession) Then Application.MailLogon
With ThisWorkbook.Worksheets("Sheet6").Cells
For Each c In .Range("D2:D12").Cells
s = c.Value
If s = "" Then GoTo Skip
Workbooks(myFile & ".xls").SendMail Recipients:=s, _
Subject:="Here is a NEW Problem Report", _
ReturnReceipt:=False 
Skip:
Next c
End With 
Workbooks(myFile & ".xls").Close False
'Now cleanup
Kill "C:\Windows\temp\" & myFile & ".xls"
End Sub
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
I got it to work, I was able to define the recipients in the macro. Now I just have to hope they wont change.
 
Upvote 0
How would I change the following line of code for multiple worksheets, or would it be better to just copy and paste the macro three times, changing the worksheet named.
 
Upvote 0

Forum statistics

Threads
1,214,387
Messages
6,119,222
Members
448,877
Latest member
gb24

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top