Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default intersect method error

I'm experimenting with the intersect method...

I need to locate two values, assign them to variables and then select
the intersection between the two.

I'm trying the following:

Sub IntersectTest()

Dim colRng, uclRng

Dim isect As Range

colRng = ActiveSheet.Cells.Find("DC_RES")

uclRng = ActiveSheet.Cells.Find("UCL")

Set isect = Application.Intersect(Range(colRng).EntireColumn,
(Range(uclRng).EntireRow))

If isect Is Nothing Then
MsgBox "Ranges do not intersect"
Else
isect.Select
End If

End Sub

At the Set isect =... line I get:
Run time error : '1004'
Method 'Range' of 'object' Global Failed

Help! I've rewritten this as many ways as I can, to no avail.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default intersect method error

If either of those .finds were unsuccessful, then you'll have trouble.

I'd check for that first.

Sub IntersectTest()

'declare those variables as Ranges.
Dim colRng as Range
dim uclRng as range
Dim isect As Range

'use the Set command to assign a range to that range variable
set colRng = ActiveSheet.Cells.Find("DC_RES")
set uclRng = ActiveSheet.Cells.Find("UCL")

if colrng is nothing _
or uclrng is nothing then
msgbox "at least one find failed!
else
Set isect = Application.Intersect(colRng.EntireColumn, uclRng.EntireRow)
'and there'll always be an intersection with a row and column.
isect.Select
End If

End Sub

wrote:

I'm experimenting with the intersect method...

I need to locate two values, assign them to variables and then select
the intersection between the two.

I'm trying the following:

Sub IntersectTest()

Dim colRng, uclRng

Dim isect As Range

colRng = ActiveSheet.Cells.Find("DC_RES")

uclRng = ActiveSheet.Cells.Find("UCL")

Set isect = Application.Intersect(Range(colRng).EntireColumn,
(Range(uclRng).EntireRow))

If isect Is Nothing Then
MsgBox "Ranges do not intersect"
Else
isect.Select
End If

End Sub

At the Set isect =... line I get:
Run time error : '1004'
Method 'Range' of 'object' Global Failed

Help! I've rewritten this as many ways as I can, to no avail.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default intersect method error

Sub IntersectTest()

Dim colRng as Range, uclRng as Range

Dim isect As Range

set colRng = ActiveSheet.Cells.Find("DC_RES")

set uclRng = ActiveSheet.Cells.Find("UCL")
if colRng is nothing or uclRng is nothing then
msgbox "Not found"
Exit sub
end if
Set isect = Application.Intersect(colRng.EntireColumn, _
uclRng.EntireRow))

' it would be difficult for a row and column not to intersect


End Sub

--
Regards,
Tom Ogilvy

wrote in message
ups.com...
I'm experimenting with the intersect method...

I need to locate two values, assign them to variables and then select
the intersection between the two.

I'm trying the following:

Sub IntersectTest()

Dim colRng, uclRng

Dim isect As Range

colRng = ActiveSheet.Cells.Find("DC_RES")

uclRng = ActiveSheet.Cells.Find("UCL")

Set isect = Application.Intersect(Range(colRng).EntireColumn,
(Range(uclRng).EntireRow))

If isect Is Nothing Then
MsgBox "Ranges do not intersect"
Else
isect.Select
End If

End Sub

At the Set isect =... line I get:
Run time error : '1004'
Method 'Range' of 'object' Global Failed

Help! I've rewritten this as many ways as I can, to no avail.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default intersect method error

Dave,

that works thanks :) I was getting real frustraited :(

I still get mixed up trying to make good declarations. Why do you need
to use the Set statement when assing a variabvle that is a Range type?

Thanks Again


Dave Peterson wrote:
If either of those .finds were unsuccessful, then you'll have trouble.

I'd check for that first.

Sub IntersectTest()

'declare those variables as Ranges.
Dim colRng as Range
dim uclRng as range
Dim isect As Range

'use the Set command to assign a range to that range variable
set colRng = ActiveSheet.Cells.Find("DC_RES")
set uclRng = ActiveSheet.Cells.Find("UCL")

if colrng is nothing _
or uclrng is nothing then
msgbox "at least one find failed!
else
Set isect = Application.Intersect(colRng.EntireColumn, uclRng.EntireRow)
'and there'll always be an intersection with a row and column.
isect.Select
End If

End Sub

wrote:

I'm experimenting with the intersect method...

I need to locate two values, assign them to variables and then select
the intersection between the two.

I'm trying the following:

Sub IntersectTest()

Dim colRng, uclRng

Dim isect As Range

colRng = ActiveSheet.Cells.Find("DC_RES")

uclRng = ActiveSheet.Cells.Find("UCL")

Set isect = Application.Intersect(Range(colRng).EntireColumn,
(Range(uclRng).EntireRow))

If isect Is Nothing Then
MsgBox "Ranges do not intersect"
Else
isect.Select
End If

End Sub

At the Set isect =... line I get:
Run time error : '1004'
Method 'Range' of 'object' Global Failed

Help! I've rewritten this as many ways as I can, to no avail.


--

Dave Peterson


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default intersect method error

You use set to assign an object to an object variable.

You use let to assign a value to a normal variable. However, the let can
be omitted and usually is.



--
Regards,
Tom Ogilvy

wrote in message
oups.com...
Dave,

that works thanks :) I was getting real frustraited :(

I still get mixed up trying to make good declarations. Why do you need
to use the Set statement when assing a variabvle that is a Range type?

Thanks Again


Dave Peterson wrote:
If either of those .finds were unsuccessful, then you'll have trouble.

I'd check for that first.

Sub IntersectTest()

'declare those variables as Ranges.
Dim colRng as Range
dim uclRng as range
Dim isect As Range

'use the Set command to assign a range to that range variable
set colRng = ActiveSheet.Cells.Find("DC_RES")
set uclRng = ActiveSheet.Cells.Find("UCL")

if colrng is nothing _
or uclrng is nothing then
msgbox "at least one find failed!
else
Set isect = Application.Intersect(colRng.EntireColumn,
uclRng.EntireRow)
'and there'll always be an intersection with a row and column.
isect.Select
End If

End Sub

wrote:

I'm experimenting with the intersect method...

I need to locate two values, assign them to variables and then select
the intersection between the two.

I'm trying the following:

Sub IntersectTest()

Dim colRng, uclRng

Dim isect As Range

colRng = ActiveSheet.Cells.Find("DC_RES")

uclRng = ActiveSheet.Cells.Find("UCL")

Set isect = Application.Intersect(Range(colRng).EntireColumn,
(Range(uclRng).EntireRow))

If isect Is Nothing Then
MsgBox "Ranges do not intersect"
Else
isect.Select
End If

End Sub

At the Set isect =... line I get:
Run time error : '1004'
Method 'Range' of 'object' Global Failed

Help! I've rewritten this as many ways as I can, to no avail.


--

Dave Peterson






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default intersect method error

Ok, I think I have it now. When I say "as Range" Im declaring an
object variable. I was under the misunderstanding that in this case
"range" was just a data type... Embarasing that as much as I have read
about declaring and setting variables I didnt get that.

Thanks Tom!
Robert

Tom Ogilvy wrote:
You use set to assign an object to an object variable.

You use let to assign a value to a normal variable. However, the let can
be omitted and usually is.



--
Regards,
Tom Ogilvy

wrote in message
oups.com...
Dave,

that works thanks :) I was getting real frustraited :(

I still get mixed up trying to make good declarations. Why do you need
to use the Set statement when assing a variabvle that is a Range type?

Thanks Again


Dave Peterson wrote:
If either of those .finds were unsuccessful, then you'll have trouble.

I'd check for that first.

Sub IntersectTest()

'declare those variables as Ranges.
Dim colRng as Range
dim uclRng as range
Dim isect As Range

'use the Set command to assign a range to that range variable
set colRng = ActiveSheet.Cells.Find("DC_RES")
set uclRng = ActiveSheet.Cells.Find("UCL")

if colrng is nothing _
or uclrng is nothing then
msgbox "at least one find failed!
else
Set isect = Application.Intersect(colRng.EntireColumn,
uclRng.EntireRow)
'and there'll always be an intersection with a row and column.
isect.Select
End If

End Sub

wrote:

I'm experimenting with the intersect method...

I need to locate two values, assign them to variables and then select
the intersection between the two.

I'm trying the following:

Sub IntersectTest()

Dim colRng, uclRng

Dim isect As Range

colRng = ActiveSheet.Cells.Find("DC_RES")

uclRng = ActiveSheet.Cells.Find("UCL")

Set isect = Application.Intersect(Range(colRng).EntireColumn,
(Range(uclRng).EntireRow))

If isect Is Nothing Then
MsgBox "Ranges do not intersect"
Else
isect.Select
End If

End Sub

At the Set isect =... line I get:
Run time error : '1004'
Method 'Range' of 'object' Global Failed

Help! I've rewritten this as many ways as I can, to no avail.

--

Dave Peterson



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
Intersect Method Arne Hegefors Excel Programming 3 August 21st 06 12:15 PM
Error 424 with inputbox method after OK Herman[_4_] Excel Programming 1 September 14th 04 11:12 PM
Method 'Intersect' of object '_Global' failed Josh Sale Excel Programming 3 June 17th 04 05:27 PM
Exception when uisng Intersect method Ai Excel Programming 8 May 24th 04 09:12 PM
Is there a "Non-Intersect" VBA method to remove a sub-range from a range? brettdj Excel Programming 1 December 11th 03 06:13 AM


All times are GMT +1. The time now is 10:09 PM.

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

About Us

"It's about Microsoft Excel"