Excel intersect not intersecting

QldRobbo

New member
Joined
Jan 16, 2008
Messages
1
Programming Experience
1-3
Hi,
I am creating an excel add-in in VS2008.

In an excel file I have two names ranges, range A is the entire A column, Range B is the entire first row.

To get where the two ranges intersect I use the intersect method of excel which returns the A1 cell.

I am getting a single cell using this for around 350 different named ranges (all rows) over around 22 columns.

However, randomly the intersect method doesn't return the single cell, it returns the entire range B (the whole row). It does around every other time I run the code, and it does it on different named ranges, at different times (sometimes at the start, sometimes at the end).

Has anyone got any ideas why this might be the case?

The code has the form of

VB.NET:
Foreach column in columns ' Around 22 columns
value = excel.intersect(range("row1"),column).value
value2 = excel.intersect(range("row2"),column).value
value3 = excel.intersect(range("row3"),column).value
... around 350 rows ..
next

I have tried using a counter and getting the columns specifically but that does the same thing, sometimes ignores the columns property and returns the whole range...

eg
VB.NET:
For i = 0 to columns.count
value = range("row1").columns(i).value
value2 = range("row2").columns(i).value
value2 = range("row2").columns(i).value
Next

That does the same thing randomly, returns just range("row1"), not column i from range("row1")

Any help appreciated.

Rob
 

Latest posts

Back
Top