Good morning,
I have this code below that send an email with an attachement (excel file) and a table in email's body.
Sub Email()
Dim outapplication As Object
Dim nEmail As Object
Set outapplication = CreateObject("outlook.application")
Set nEmail = outapplication.CreateItem(olMailItem)
strTime = Date
With nEmail
.Display
.To = "example@outlook.com"
.CC = ""
.Subject = "Email's title" & " " & strTime
.attachaments.Add "G:\path\test.XLSX"
With .GetInspector.WordEditor.Windows(1).Selection
.typetext "E-mail's body"
.typeParagraph
.typeParagraph
.typetext "Following the table:"
.typeParagraph
.typeParagraph
.typeParagraph
Sheets("TOP").Select
ActiveSheet.Range("a1:B21").Copy 'Here to change the code
.Paste
.typeParagraph
.typeParagraph
Application.CutCopyMode = False
End With
.Send
End With
Set outapplication = Nothing
Set nEmail = Nothing
End Sub
-I would like to instead of selecting a specific table (as it is from "a1:b21"), I would like the code to check the last column and the last row of the table.