Feb 24 2020 03:07 PM
Hi,
I have a daily task which requires me to get data from a pdf each day and then send as a CSV file to another email. I am looking to have a macro to be able to send one tab of an excel as a CSV file to the email address listed on the tab. From my research i have found the below macro to send a tab as CSV.
Public Sub Email_Sheets_As_CSV() Dim csvFiles(1 To 3) As String, i As Integer Dim wsName As Variant Dim OutApp As Object, OutMail As Object i = 0 For Each wsName In Array("Sheet1", "Sheet2", "Sheet3") 'sheet names to be emailed - CHANGE THE NAMES i = i + 1 csvFiles(i) = ThisWorkbook.Path & "\" & wsName & ".csv" ThisWorkbook.Worksheets(wsName).Copy ActiveWorkbook.SaveAs csvFiles(i), FileFormat:=xlCSV ActiveWorkbook.Close False Next 'Email the .csv files Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItem(0) With OutMail .To = ThisWorkbook.Worksheets("Settings").Range("A1").Value 'cell containing email address - CHANGE THE SHEET & CELL .CC = "" .BCC = "" .Subject = "Email subject here" .Body = "This email contains 3 .csv file attachments." .Attachments.Add csvFiles(1) .Attachments.Add csvFiles(2) .Attachments.Add csvFiles(3) .Send End With On Error GoTo 0 Set OutMail = Nothing Set OutApp = Nothing 'Delete the .csv files Kill csvFiles(1) Kill csvFiles(2) Kill csvFiles(3) End Sub
Can someone please assist in updating this to so it reads the tab "Upload CSV" to send an email address listed in cell B5?
Thank you kindly for any assistance.
Mar 03 2020 06:33 AM
SolutionMar 03 2020 07:45 PM
Thank you greatly for your help with this.
I will update and complete some testing shortly.
Thanks again for your help, much appreciated.
Mar 03 2020 06:33 AM
Solution