Excel VBA Macro to Copy a Worksheet and Email It
Question details
Create an Excel VBA workflow that copies a worksheet, converts formulas to values while retaining formatting, and emails the new workbook to addresses in a worksheet column.

- Product
- Microsoft Excel and Microsoft Outlook
- Device & OS
- not provided
- Scenario
- A user wants to distribute a formatted worksheet as a separate workbook to recipients listed in Excel.
- Observed behavior
- The desired result is a values-only workbook attached to an Outlook email addressed to the listed recipients.
Use desktop Excel with VBA enabled and classic Outlook for Windows configured with a mail account. Name the sheet to copy Report, and put recipient addresses on a Recipients sheet in column A, starting at A2; adjust the names or starting row in the macro if needed.
Create a values-only workbook and prepare an Outlook email
Use this VBA macro to copy the Report sheet, retain its formatting, and create one email addressed to the recipients listed in column A.
The macro opens the message for review rather than sending it automatically. It saves the copied sheet as an XLSX file in the Windows temporary folder.
The values conversion may require adjustment for merged cells or array formulas. Test it on a representative sheet and check the resulting workbook before sending.
In Excel, open the workbook containing the Report and Recipients sheets. Press Alt+F11, then choose Insert > Module.
Paste this code into the module: Sub EmailReport() Dim sourceSheet As Worksheet, recipientSheet As Worksheet Dim newBook As Workbook, outlookApp As Object, mail As Object Dim lastRow As Long, i As Long Dim addresses As String, address As String, filePath As String Dim errorMessage As String On Error GoTo Failed Set sourceSheet = ThisWorkbook.Worksheets("Report") Set recipientSheet = ThisWorkbook.Worksheets("Recipients") lastRow = recipientSheet.Cells(recipientSheet.Rows.Count, "A").End(xlUp).Row For i = 2 To lastRow address = Trim$(CStr(recipientSheet.Cells(i, "A").Value)) If Len(address) > 0 Then If Len(addresses) > 0 Then addresses = addresses & ";" addresses = addresses & address End If Next i If Len(addresses) = 0 Then MsgBox "No recipients found in column A.", vbExclamation Exit Sub End If filePath = Environ$("TEMP") & "\Report_" & Format$(Now, "yyyymmdd_hhnnss") & ".xlsx" If Len(Dir$(filePath)) > 0 Then MsgBox "The output file already exists. Wait a moment and try again.", vbExclamation Exit Sub End If sourceSheet.Copy Set newBook = ActiveWorkbook With newBook.Worksheets(1).UsedRange .Value = .Value End With newBook.SaveAs Filename:=filePath, FileFormat:=51 newBook.Close SaveChanges:=False Set newBook = Nothing Set outlookApp = CreateObject("Outlook.Application") Set mail = outlookApp.CreateItem(0) With mail .To = addresses .Subject = "Report" .Body = "Please find the report attached." .Attachments.Add filePath .Display End With Exit Sub Failed: errorMessage = Err.Description On Error Resume Next If Not newBook Is Nothing Then newBook.Close SaveChanges:=False MsgBox "Could not prepare the email: " & errorMessage, vbExclamation End Sub
Return to Excel, press Alt+F8, select EmailReport, and click Run. In the Outlook message, check the recipients, subject, and attachment, then click Send.

Work with Excel reports in WPS Office
WPS Office is a free, lightweight alternative for opening and editing spreadsheets with a familiar interface, making it easy to move routine report work between Office formats. It does not fix Outlook security prompts or guarantee that this Excel VBA macro will run unchanged.

Frequently Asked Questions
Why does Outlook ask me to allow programmatic access?
Outlook may display a security prompt when another program accesses or sends mail. In classic Outlook, check File > Options > Trust Center > Trust Center Settings > Programmatic Access; available settings can depend on antivirus status and organizational policy.
Does the macro send a separate email to each address?
No. It combines the addresses from Recipients!A2 downward in the To field of one message. Review the recipient list before clicking Send.
How do I use different worksheet names?
In the VBA editor, change Worksheets("Report") and Worksheets("Recipients") to match the sheet tabs in your workbook. The macro reads addresses from column A starting at row 2.
Where is the copied workbook saved?
The macro saves an XLSX file with a Report_ timestamped name in the Windows temporary folder, then attaches that file to the Outlook message.
Will the copied workbook keep its formulas?
No. The macro replaces formulas in the copied sheet's used range with their current values while retaining formatting. Check the result, especially if the sheet contains merged cells or array formulas.




