E-mail the contents of your Excel file using VBA

The below code mails a range of 20 cells, A1 through B10, from the currently active workbook to the e-mail address specified in the code:

Sub EmailRange()

' Select the range of cells on the active worksheet.
ActiveSheet.Range("A1:B10").Select

' Show the envelope on the ActiveWorkbook.
ActiveWorkbook.EnvelopeVisible = True

' Set the optional introduction field thats adds
' some header text to the email body. It also sets
' the To and Subject lines. Finally the message
' is sent.
With ActiveSheet.MailEnvelope
.Introduction = "This is a sample worksheet."
.Item.To = "SomeOne@XYZ.com"
.Item.Subject = "subject line"
.Item.Send
End With
End Sub

Note This code only works with Microsoft Outlook. Replace E-Mail Address here with the e-mail address that you want to send the range to.

Note Item.Send in the code triggers an Outlook security warning to display the following message:
A program is trying to automatically send e-mail on your behalf. Do you want to allow this? If this is unexpected, it may be a virus and you should choose "No".

Click Yes to allow the mail to be sent.