VBA code for multiply ranges from more than one Sheet

2avrham

Board Regular
Joined
May 12, 2014
Messages
104
Office Version
  1. 365
I'm training to write VBA code that combine two sheets data rage to one email and send it. I used below code for my debug but I failed to do so time after time. Below code send one sheet range data and I want to add it additional rage from sheet2 (Worksheets("Sheet2").Range("b3:b30")

Sub Mail_take_2()

Dim AWorksheet As Worksheet
Dim Sendrng As Range
Dim rng As Range

On Error GoTo StopMacro With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Set Sendrng = Worksheets("Sheet1").Range("c2:j45")

Set AWorksheet = ActiveSheet

With Sendrng

.Parent.Select

Set rng = ActiveCell

.Select

ActiveWorkbook.EnvelopeVisible = True
With .Parent.MailEnvelope

.Introduction = "This is test mail 2."

With .Item
.To = "aaa@aa.com"
.CC = ""
.BCC = ""
.Subject = "My subject"
.Send
End With

End With

rng.Select
End With

AWorksheet.Select

StopMacro:
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
ActiveWorkbook.EnvelopeVisible = False

End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,223,275
Messages
6,171,121
Members
452,381
Latest member
Nova88

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