Add a 'Check Names' in VBA Code

QMAN223

New Member
Joined
Nov 24, 2021
Messages
36
Office Version
  1. 365
Platform
  1. Windows
Hi,

I would like to add a 'Check Names' object to my Code.

My code refers to a table, named 'Leavers' so that the users of the Macro File can update it with ease by adding/removing recipients without messing with the code.

I'm using Office 365.

Here is my code:

VBA Code:
Sub Leavers()
    Dim OutApp As Object, OutMail As Object
    Dim emailTo As String, emailCC As String
    Dim PrevMnthYear As Date
    Dim c As Range
    
    PrevMnthYear = Format(DateAdd("m", -1, Date), "mmmm yyyy")
    
    emailTo = WorksheetFunction.TextJoin(";", True, ActiveSheet.Range("Leavers[To]"))
    emailCC = WorksheetFunction.TextJoin(";", True, ActiveSheet.Range("Leavers[CC]"))
     
        Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)
        With OutMail
            .To = emailTo
            .CC = emailCC
            .Subject = Format(DateAdd("m", -1, Date), "mmmm yyyy") & " -  Leavers Report"
            .Body = "Dear colleagues," & vbCrLf & vbCrLf & _
            "Please find attached a Leavers report for " & Format(DateAdd("m", -1, Date), "mmmm yyyy") & vbCrLf & vbCrLf & "Best wishes,"
            '.Attachments.Add 
            OutMail.display
        End With

End Sub

Thanks in advance!
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,214,798
Messages
6,121,636
Members
449,043
Latest member
farhansadik

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