Emailing a formatted table

Elliottj2121

Board Regular
Joined
Apr 15, 2021
Messages
50
Office Version
  1. 365
  2. 2019
Platform
  1. 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

1631628375808.png

1631628615378.png
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,214,806
Messages
6,121,672
Members
449,045
Latest member
Marcus05

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