ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Union Function (https://www.excelbanter.com/excel-programming/394279-union-function.html)

NutoVBA

Union Function
 
I am trying to combine data on two different sheets in the same workbook
using the following command:
Set Union_sh = Application.Union(Sheets("BSPL+"), Sheets("Other OMI"))

For some reason this won't work and I cannot understand why.

JE McGimpsey

Union Function
 
First, the Union method requires Range object arguments, not Sheet
objects.

Second, the Union method returns a Range object, which is a child object
of a Sheet. You can't have a Range Object that has two parent (sheet)
objects.



In article ,
NutoVBA wrote:

I am trying to combine data on two different sheets in the same workbook
using the following command:
Set Union_sh = Application.Union(Sheets("BSPL+"), Sheets("Other OMI"))

For some reason this won't work and I cannot understand why.


NutoVBA

Union Function
 
Do you have any ideas on how to identify a sheet as a Range?

"JE McGimpsey" wrote:

First, the Union method requires Range object arguments, not Sheet
objects.

Second, the Union method returns a Range object, which is a child object
of a Sheet. You can't have a Range Object that has two parent (sheet)
objects.



In article ,
NutoVBA wrote:

I am trying to combine data on two different sheets in the same workbook
using the following command:
Set Union_sh = Application.Union(Sheets("BSPL+"), Sheets("Other OMI"))

For some reason this won't work and I cannot understand why.



JE McGimpsey

Union Function
 
Sheet Objects and Range Objects are not, and cannot be made equivalent.

You can return a range object consisting of all cells on a sheet with

Sheets("Sheet1").Cells



In article ,
NutoVBA wrote:

Do you have any ideas on how to identify a sheet as a Range?



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

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