In MS Excel VBA, the End property applies to Cell object, not Cells. I wonder if Aspose can provide the same property for Aspose.Excel. It would really help to determine the end cell if the size of table is unknown. Here is Microsoft’s documentation:
Returns a Range object that represents the cell at the end of the region that contains the source range. Equivalent to pressing END+UP ARROW, END+DOWN ARROW, END+LEFT ARROW, or END+RIGHT ARROW. Read-only.
Syntax
expression.End(Direction)
expression Required. An expression that returns a Range object.
Direction Required Long. The direction in which to move. Can be one of the following XlDirection constants: xlToLeft, xlToRight, xlUp, or xlDown.
======================================================
End Property Example
This example selects the cell at the top of column B in the region that contains cell B4.
Range(“B4”).End(xlUp).Select
This example selects the cell at the end of row 4 in the region that contains cell B4.
Range(“B4”).End(xlToRight).Select
This example extends the selection from cell B4 to the last cell in row four that contains data.
Worksheets(“Sheet1”).Activate
Range(“B4”, Range(“B4”).End(xlToRight)).Select
Hi Harrison,
Could Cells.End property meet your need? If not, I will add this property as your wish. I think Cells.End is also easy to use.
Hi Laurence,
Cells.End could not find the end cell of a table that starts somewhere in the midde of a worksheet. Furthermore, Cells.End can only the end cell of a whole sheet, not a table.
For example:
In sheet “Sheet1”, I have two tables:
1) Table 1: B1:E20
2) Table 2: G1:W100
Cells.End would give me cell W100, not what I wanted for this case. Let’s see how Cell.End works for this case:
In table 1:
Cell(“B1”).End(xlToRight) --> this would give me cell E1
Cell(“E1”).End(xlDown) --> this would give me cell E20
In table 2: (similar)
Cell(“G1”).End(xlDown) --> this would give me cell G100
Cell(“G100”).End(xlToRight) --> this would give me cell W100
There is no way Cells.End could achieve this.
Hi Harrison,
I understand your need now. I will think about how to meet your need in Aspose.Excel. It will be available within two weeks.
Hi Laurence - Was this feature added, and if so, how is it used (specifically in .NET).
For example, I want to do something like this (from the VBA):
Range(“F10”).Select
iNewHdrRow = Selection.End(xlDown).Row
to find the index of the first populated row in column “F”, after row 10. Any help would be appreciated. Thanks!
Hi,
Thank you for considering Aspose.
Well you may try Cells.EndCellInColumn() and sheet.Cells.EndCellInRow() APIs and check if these APIs can fit your need.
Thank You & Best Regards,