I'm going to show you how to join two separate ranges with the Union function
and send them on an email so here I have my two different ranges this goes down
into line six and then my new range starts at line eight and it goes down to
line 16 and so this is on sheet 2 and on sheet 1 I have my list of
emails and my subject so you could have this long list as long as it could be
please note that these these ranges are not contiguous that they have a line
between them so you could basically select two ranges from anywhere in your
data and send them on one email so I saw that I have space between my tables what
I have done is I have increased the height of row 8 and then I've taken a
lot of off the borders on the cell what we're gonna do then is why don't we run
our code so what I've named my macro is both I will of course include the code
in my description of the video and so let's run this
we'll bring the email over here and here you can see that we have the two
separate the two separate tables on here we have the first table whose just black
and white and the second one I have I have color in there
so we can just we can see that we have two separate ranges that are copied onto
this sheet so now I'll show you the code and so go to the top here so I've
declared X is an integer add a edress and subject line out looked as object new
email as object X inspectors object page editor as object and row as long
datasheet report sheet as worksheets range one as a range range two as a
range and multiple ranges as a range it's very important that you would you
declare these separately or it will get confused with them so now what I'm doing
is I setting datasheet to shoot one that's
the one sheet with my email addresses on it and report sheet to sheet 2 so I'm
dad as she'd activate last room declaring where the last row is and then
I'm saying with datasheet and to tell you have no email addresses in email
address row then you set outlook and create Outlook application set new email
as Outlook create he address as a - each cell one and subject would be in B so
set range equals report range report range being my second sheet so a1 to f6
and then I'm setting set to set the range report range a8 to f-16 and then
what I'm doing is I'm setting multiple range it was a union of range 1 and
range 2 and then the rest is basically oh and then I say multiple range copy
and then we go to the same the same thing is you go to eat to be address
subject as your subject line and there's my little piece of the body and then I'd
set excellence back to new mail get an inspector set page editor and a page out
of your worksheet page editor application select start lengths body
page editor selection end page editor application selection start page editor
application selection page paste format word word format plain text and then
I've got display I've got commented out the send because I didn't want to send
these and then I say set page editor equals nothing set inspector equals
nothing he address equals nothing and then and width and I add another one to
my X and then I loop to through and then when I'm done all the loops I set email
to nothing and Outlook to nothing so that's how you copy two separate ranges
on to an email using the Union the Union function in
VBA in Excel please subscribe