Range subtraction in the Excel Object Model
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 ma开发者_C百科ny rows/columns B
is offset from A
.
Does anyone know the easiest way to do this? Is there a library function?
Thanks.
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.
精彩评论