'What is the code to read the last row and last column of an excel table?

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 = "[email protected]"
.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.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source