How to Send a Complete Excel Worksheet with VBA and Outlook
Question details
The user needs to email a filtered Excel worksheet via a VBA procedure while preserving all formatting, data validation, and dropdown lists.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Automating the process of attaching a specific, filtered worksheet to an Outlook email using a VBA macro.
- Observed behavior
- When copying cell values to the attachment, the emailed worksheet loses its original formatting, layout design, and dropdown list functionality.
Ensure that your macro security settings allow VBA code to run and that Microsoft Outlook is properly configured as your default email client.
Use the Worksheet.Copy Method to Create a Temporary Workbook
By copying the entire worksheet object rather than just the cell values, all formatting and data validation rules are preserved in the emailed attachment.
When you copy only the cell values into a new workbook, Excel does not transfer worksheet-level features such as column widths, data validation (dropdown lists), or conditional formatting. To retain these features, you must use the Worksheet.Copy method. This generates a temporary workbook containing an exact replica of your worksheet, which can then be saved, attached to an Outlook email, and safely deleted.
In your VBA editor, use the code `ThisWorkbook.Sheets("YourSheetName").Copy`. Omitting the destination argument forces VBA to create a new workbook containing only this duplicated sheet with all formatting intact.
Assign a temporary file path using the `Environ("temp")` function and save the newly created active workbook using `ActiveWorkbook.SaveAs TempFilePath`.
Create your Outlook MailItem object in VBA using `CreateObject("Outlook.Application").CreateItem(0)`. Set your recipients and subject, and use `.Attachments.Add TempFilePath` to attach the fully formatted temporary workbook.
After using the `.Send` method to dispatch the email, close the temporary workbook without saving by typing `ActiveWorkbook.Close False`. Finally, use the `Kill TempFilePath` command to delete the temporary file from your system.

Use WPS Spreadsheet for Seamless Macro Automation
WPS Spreadsheet offers robust support for VBA and macros, enabling you to effortlessly automate repetitive tasks like filtering data, duplicating worksheets, and sending emails without compromising your document's formatting.
- 1. Open WPS Spreadsheet: Launch WPS Spreadsheet and open your macro-enabled workbook.
- 2. Access the VBA Editor: Navigate to the Developer tab and click on 'Visual Basic' to open the VBA editor interface.
- 3. Run Your Automation: Insert or run your existing Worksheet.Copy code to automatically generate and email the fully formatted attachment.

Frequently Asked Questions
Why do my dropdown lists disappear when I copy cells to a new workbook in VBA?
Dropdown lists are created using Data Validation rules. If your VBA script only copies cell values (e.g., using PasteSpecial xlPasteValues), these rules are left behind. You must copy the entire worksheet object to retain them.
Can I attach multiple worksheets to the same Outlook email using this VBA method?
Yes. Instead of copying a single sheet, you can pass an array of sheet names to the Copy method, like `ThisWorkbook.Sheets(Array("Sheet1", "Sheet2")).Copy`. This creates a single temporary workbook containing all specified sheets which can then be attached.
How do I prevent the Outlook security warning when sending emails via VBA?
Security prompts often occur when antivirus software is inactive, or if Outlook's programmatic access settings are strict. You can resolve this by updating your antivirus, adjusting Outlook's Trust Center settings for Programmatic Access, or signing your VBA macro with a trusted digital certificate.
Does this macro method work with email clients other than Microsoft Outlook?
The specific `Outlook.Application` object in VBA only interacts with Microsoft Outlook. To send emails via other clients or webmail, you would need to use CDO (Collaboration Data Objects) to send emails via SMTP directly from Excel.




