views:

47

answers:

1

When using Excel Interop libraries from .NET, I can find a Range object representing the cell offset from Range X by calling something like.

Range Y = X.Range[2,3];

But what should I do to perform the inverse operation, ie: I have two Range objects, A and B, and I would like to find out by how many rows/columns B is offset from A.

Does anyone know the easiest way to do this? Is there a library function?

Thanks.

A: 

You want Longs returned?

RowOffset = B.Cells(1,1).Row - A.Cells(1,1).Row
ColOffset = B.Cells(1,1).Column - B.Cells(1,1).Column

That will tell you how much the top left cells are offset.

Dick Kusleika