Question : Excel VBA

I have the following code used to automatically email an an updated workbook everytime it is saved to a nominated distribution list.

It is possible on save to pop up a list of potential recipients which can be ticked or somehow selected for controlled distribution.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Dim OutApp As Object
    Dim OutMail As Object
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    On Error Resume Next
    With OutMail
        .To = "[email protected];john.doe2@hotmail.com"
        .CC = ""
        .BCC = ""
        .Subject = "Status Report Notification"
        .Body = "The attached status sheet has been updated"
        .Attachments.Add ActiveWorkbook.FullName
        .Send
    End With
    On Error GoTo 0
    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub

Answer : Excel VBA

I removed your checkbox objects.  The Checkbox objects make this more complicated than it needs to be.

What I did was create a Worksheet_SelectionChange event that inputs an "R" if it's empty or input empties the cell if "R" is already there.

I then changed the font of the cells to Webdings 2 so that the R shows up as check box.   Bow when you click the cell it will either check it or uncheck it.   This allows me to check if an email needs to be added by checkinging the column for a value of "R".  Hope this makes sense.....

See attached......

 
Click Cells to check them
 
Random Solutions  
 
programming4us programming4us