Elliottj2121
Board Regular
- Joined
- Apr 15, 2021
- Messages
- 50
- Office Version
- 365
- 2019
- Platform
- Windows
Hello everyone! I am looking for some help copying over a table from Excel to Outlook in the body of an email and send it to specific addresses. I have written a macro to format it how I like, but I am having trouble figuring out to copy it over to email. Image #1 is the original data pulled from a database query and image #2 is the desired result from the formatting macro I wrote. The columns are constant but the rows can vary depending on how many invoices there are. The code to email the table I have started is below also. Any help would be so greatly appreciated!
VBA Code:
Sub CopyToEmail(wkbCrow As Workbook)
Dim wsCrow As Worksheet
Set wsCrow = wkbCrow.Worksheets(1)
Dim r As Variant, c As Variant, CrowLR As Variant, CrowLC As Variant
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
CrowLR = LastRow(wsCrow)
CrowLC = LastColumn(wsCrow)
Columns("A:G").AutoFit
Columns("D:F").Style = "Currency"
With wsCrow
For r = 1 To CrowLR
For c = 1 To 7
.Cells(r, c).Select
Next
Next
End With
End Sub