Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ai Ai is offline
external usenet poster
 
Posts: 3
Default Exception when uisng Intersect method

H

It seems that if the range 1 and range2 in Intersect (Range range1, Range ranges2 , ...) are in different worksheets this method throws HRESULT: 0x800A03EC exception. I am using c#.

Looking for your advice

Ai
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Exception when uisng Intersect method

Hi
why do you want to test this kind of ranges with
Intersect. They could never Intersect if they're on
different sheets?

-----Original Message-----
Hi

It seems that if the range 1 and range2 in Intersect

(Range range1, Range ranges2 , ...) are in different
worksheets this method throws HRESULT: 0x800A03EC
exception. I am using c#.

Looking for your advice.

Ai
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default Exception when uisng Intersect method

"?B?QWk=?=" wrote...
It seems that if the range 1 and range2 in Intersect (Range range1, Range
ranges2 , ...) are in different worksheets this method throws HRESULT:
0x800A03EC exception. I am using c#.


C# provides syntax for exception handling through try..catch..finally blocks. It
may prove more efficient to trap the exceptions than to compare objects'
parents' and grandparents' names. Note that C# also has an 'is' operator, but it
functions like VBA's 'TypeOf x Is y', not like VBA's plain 'Is' operator. It's
unclear to me (maybe just because I don't have an MSDN subscription or a lot of
VB[A] books) whether VBA's 'Is' operator is a reference or value equality
operator. In C terms, whether it's checking that pointers are pointing to the
same piece of memory or whether what they're pointing to is the same.

Going the opposite direction that Tushar and Tom went in discussing Is vs .Name,
as long as your range objects aren't NULL/Nothing (easily checked), you can
safely access their Address properties. You can compare Address(,,, 1) results
from all range objects up to the rightmost exclamation point in each(since
exclamation points may appear in workbook directory and filenames, but not in
range addresses). If they're the same, then you can use Intersect (and Union)
without throwing an exception.

With regard to string comparisons using Name properties, don't use Name
properties to check for the same worksheets. Use Index properties and integer
comparisons instead. For workbooks, since there's a possibility multiple Excel
application instances could be involved, don't use Name properties to check for
the same workbooks. Use FullName properties to make absolutely sure that you're
not working with ranges from workbooks with the same base filename but stored in
different directories.

--
To top-post is human, to bottom-post and snip is sublime.
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
Uisng the Max and Index function to link to other workbooks Marilyn Excel Discussion (Misc queries) 1 October 6th 09 06:56 PM
Uisng an option group query mohd21uk via OfficeKB.com New Users to Excel 0 May 26th 06 12:34 PM
calculating a weighted average uisng formula bob green Excel Worksheet Functions 1 August 1st 05 06:31 AM
Access a internet Web Site uisng a macro done with excel [email protected] Excel Programming 1 April 1st 04 05:14 AM
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 12:11 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"