checkbox to remove recipient from email

R

Ron de Bruin

I posted this

********************************************
I have not see the file but
Try this

Sub Mail_Every_Worksheet()
Dim sh As Worksheet
Dim wb As Workbook
Application.ScreenUpdating = False
'loop through each wookbook
For Each sh In ThisWorkbook.Worksheets
sh.Copy
Set wb = ActiveWorkbook
With wb
Dim strdate As String
Dim firstName As String
strdate = Format(Now, "mm-dd-yy")
'Get the employee's first name from b2
firstName = sh.Range("b2").Value
.SaveAs firstName & "'s Leave Hours as of " & " " & strdate & ".xls"
'check to see if this person wants a copy of the leave statement
If wb.Sheets(1).CheckBox1.Value = False Then
'send statement of leave to employee
.SendMail ActiveSheet.Range("e2").Value, _
firstName & "'s Leave Hours as of " & " " & strdate
End If
'check to see if this person wants a copy of the leave statement
If wb.Sheets(1).CheckBox2.Value = False Then
'send copy to employee's supervisor
.SendMail ActiveSheet.Range("e5").Value, _
"Your employee " & firstName & "'s Leave Hours as of " & " " & strdate
End If

.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Next sh
'end of loop
Application.ScreenUpdating = True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top