Hi,
I am learning the ways of VBA and struggling to produce a macro that will:
1. Copy a snapshot of a fixed range B4:G34 (this will not change). This data is on the sheet "product", which is the 14th sheet in my workbook.
2. Paste Snapshot into an email and auto send.
I have produced the code below but i have 1 or 2 errors that keep occurring:
1. Variable not defined
2. Select Method of range class failed
Errors appear to related to the highlighted lines.
---------
Option Explicit
----------
Sub Send_Email_With_Snapshot1()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Sheet14")
Dim lr As Integer
lr = sh.Range("A" & Application.Rows.Count).End(xlUp).Row
sh.Range("A1:G" & lr).Select
With Selection.Parent.MailEnvelop.Item
.to = "Test@test.com"
.Subject = "Product"
.send
End With
MsgBox "Sent"
End Sub
------
I am learning the ways of VBA and struggling to produce a macro that will:
1. Copy a snapshot of a fixed range B4:G34 (this will not change). This data is on the sheet "product", which is the 14th sheet in my workbook.
2. Paste Snapshot into an email and auto send.
I have produced the code below but i have 1 or 2 errors that keep occurring:
1. Variable not defined
2. Select Method of range class failed
Errors appear to related to the highlighted lines.
---------
Option Explicit
----------
Sub Send_Email_With_Snapshot1()
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Sheet14")
Dim lr As Integer
lr = sh.Range("A" & Application.Rows.Count).End(xlUp).Row
sh.Range("A1:G" & lr).Select
With Selection.Parent.MailEnvelop.Item
.to = "Test@test.com"
.Subject = "Product"
.send
End With
MsgBox "Sent"
End Sub
------