ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy two ranges without the interval rows to the email (https://www.excelbanter.com/excel-programming/413177-copy-two-ranges-without-interval-rows-email.html)

chelsea

Copy two ranges without the interval rows to the email
 
Hi,

what i intend to do is that i just want to copy two
ranges(range("A1:L2"),rng2=("A5:L5")) from excel to an email.
i use the vba as below:
union(range("A1:L2"),rng2=("A5:L5")).copy
it can get the right result in the excel,while i paste it in the email it
display the whole range("a1:l5").
i am very confused about why it get the different result£¿

can anybody give a guide?

Regards,
Chelsea



joel

Copy two ranges without the interval rows to the email
 
To help debug these type problems I sometimes resort to SELECTION.

I would do
union(range("A1:L2"),rng2=("A5:L5")).select

Then look at the worksheet to see what is selected.

Then try

set CopyRange = union(range("A1:L2"),rng2=("A5:L5"))
CopyRange.Select

And see if the same results occur. If this is correct then you can replace
your code with

set CopyRange = union(range("A1:L2"),rng2=("A5:L5"))
CopyRange.Copy



"chelsea" wrote:

Hi,

what i intend to do is that i just want to copy two
ranges(range("A1:L2"),rng2=("A5:L5")) from excel to an email.
i use the vba as below:
union(range("A1:L2"),rng2=("A5:L5")).copy
it can get the right result in the excel,while i paste it in the email it
display the whole range("a1:l5").
i am very confused about why it get the different result£¿

can anybody give a guide?

Regards,
Chelsea




joel

Copy two ranges without the interval rows to the email
 
I just noticed the rng2. I think this should be

from
union(range("A1:L2"),rng2=("A5:L5")).copy

to
union(range("A1:L2"),rng2:=Range("A5:L5")).copy

or just
union(range("A1:L2"),range("A5:L5")).copy


"chelsea" wrote:

Hi,

what i intend to do is that i just want to copy two
ranges(range("A1:L2"),rng2=("A5:L5")) from excel to an email.
i use the vba as below:
union(range("A1:L2"),rng2=("A5:L5")).copy
it can get the right result in the excel,while i paste it in the email it
display the whole range("a1:l5").
i am very confused about why it get the different result£¿

can anybody give a guide?

Regards,
Chelsea





All times are GMT +1. The time now is 06:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com