Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Method 'Union' of object '_Application' failed (Runtime Error 1004

Hi,

I'm trying to select two disjoint ranges of cells.

Here is my code:

Dim r1 As Range
Dim r2 As Range
Set r1 = Names("SS_ChurnAssums").RefersToRange.Offset(1, 0)
Set r2 = Range(Names("SS_WeightedChurn").RefersToRange.Offs et(1, 0),
Names("SS_WeightedChurn").RefersToRange.Offset(i, 0))

Application.Union(r1, r2).Select ' <-- Error thrown here.

I verified that r1 and r2 are valid ranges (by calling the .select method
and checking if they were selected). So the error is in the Application.Union
line. I search tons of places for a solution, and many ppl seem to be getting
the same problem.

What am i doing wrong?
Is there another way to select multiple ranges?

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Method 'Union' of object '_Application' failed (Runtime Error 1004

Sub demt()
Set r1 = Range("A1")
Set r2 = Range("A2")
Application.Union(r1, r2).Select
End Sub

will work

Sub demt()
Set r1 = Sheets("Sheet1").Range("A1")
Set r2 = Sheets("Sheet2").Range("A2")
Application.Union(r1, r2).Select
End Sub

will throw a 1004 eror.


Are you sure the two ranges are on the same sheet??
--
Gary''s Student - gsnu200731


"vivmaha" wrote:

Hi,

I'm trying to select two disjoint ranges of cells.

Here is my code:

Dim r1 As Range
Dim r2 As Range
Set r1 = Names("SS_ChurnAssums").RefersToRange.Offset(1, 0)
Set r2 = Range(Names("SS_WeightedChurn").RefersToRange.Offs et(1, 0),
Names("SS_WeightedChurn").RefersToRange.Offset(i, 0))

Application.Union(r1, r2).Select ' <-- Error thrown here.

I verified that r1 and r2 are valid ranges (by calling the .select method
and checking if they were selected). So the error is in the Application.Union
line. I search tons of places for a solution, and many ppl seem to be getting
the same problem.

What am i doing wrong?
Is there another way to select multiple ranges?

Thanks.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Method 'Union' of object '_Application' failed (Runtime Error

They are in different sheets. Is it not possible to union two selections from
different worksheets?

Thanks.

"Gary''s Student" wrote:

Sub demt()
Set r1 = Range("A1")
Set r2 = Range("A2")
Application.Union(r1, r2).Select
End Sub

will work

Sub demt()
Set r1 = Sheets("Sheet1").Range("A1")
Set r2 = Sheets("Sheet2").Range("A2")
Application.Union(r1, r2).Select
End Sub

will throw a 1004 eror.


Are you sure the two ranges are on the same sheet??
--
Gary''s Student - gsnu200731


"vivmaha" wrote:

Hi,

I'm trying to select two disjoint ranges of cells.

Here is my code:

Dim r1 As Range
Dim r2 As Range
Set r1 = Names("SS_ChurnAssums").RefersToRange.Offset(1, 0)
Set r2 = Range(Names("SS_WeightedChurn").RefersToRange.Offs et(1, 0),
Names("SS_WeightedChurn").RefersToRange.Offset(i, 0))

Application.Union(r1, r2).Select ' <-- Error thrown here.

I verified that r1 and r2 are valid ranges (by calling the .select method
and checking if they were selected). So the error is in the Application.Union
line. I search tons of places for a solution, and many ppl seem to be getting
the same problem.

What am i doing wrong?
Is there another way to select multiple ranges?

Thanks.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Method 'Union' of object '_Application' failed (Runtime Error

Nope... Not possible. Woorkbooks contain worksheets and worksheets contain
ranges. The same way one sheet can not span two workbooks, one range can not
span two sheets...
--
HTH...

Jim Thomlinson


"vivmaha" wrote:

They are in different sheets. Is it not possible to union two selections from
different worksheets?

Thanks.

"Gary''s Student" wrote:

Sub demt()
Set r1 = Range("A1")
Set r2 = Range("A2")
Application.Union(r1, r2).Select
End Sub

will work

Sub demt()
Set r1 = Sheets("Sheet1").Range("A1")
Set r2 = Sheets("Sheet2").Range("A2")
Application.Union(r1, r2).Select
End Sub

will throw a 1004 eror.


Are you sure the two ranges are on the same sheet??
--
Gary''s Student - gsnu200731


"vivmaha" wrote:

Hi,

I'm trying to select two disjoint ranges of cells.

Here is my code:

Dim r1 As Range
Dim r2 As Range
Set r1 = Names("SS_ChurnAssums").RefersToRange.Offset(1, 0)
Set r2 = Range(Names("SS_WeightedChurn").RefersToRange.Offs et(1, 0),
Names("SS_WeightedChurn").RefersToRange.Offset(i, 0))

Application.Union(r1, r2).Select ' <-- Error thrown here.

I verified that r1 and r2 are valid ranges (by calling the .select method
and checking if they were selected). So the error is in the Application.Union
line. I search tons of places for a solution, and many ppl seem to be getting
the same problem.

What am i doing wrong?
Is there another way to select multiple ranges?

Thanks.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Runtime Error '1004' Method 'ActiveChart' of Object '_Global' failed [email protected] Excel Programming 6 January 30th 07 05:02 PM
runtime error 1004 method range of object global failed dreamz[_26_] Excel Programming 3 January 26th 06 07:23 PM
runtime error 1004 method range of object '_global failed valdesd Excel Discussion (Misc queries) 2 October 6th 05 07:26 PM
1004 Method 'COMAddIns' of object '_Application' failed matt Excel Programming 0 December 15th 03 05:23 PM
1004 method 'COMAddIns' of object '_Application' failed matt Excel Programming 0 December 15th 03 02:32 PM


All times are GMT +1. The time now is 11:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"