I want to select all non-empty cells from the current cell to the last cell of the row.
If we use
currentRange.End[XlDirection.xlToRight]
this is a bad approach when non-empty cells do not touch the link . For example, cells A1, A2, A3, A5, A6 are not empty, then RangeA1.End[XlDirection.xlToRight] is suitable only for A3, that is, the last non-empty cell associated with RangeA1.
Another option:
CreateRange(currentRange, lastRangePossibleinRow).SpecialCells(...)
I have 3 questions:
currentRange.End[XlDirection.xlToRight] seems like an unreliable solution. For example, if currentRange is empty, it will still return 1 cell (itself).
How to increase the selection of the current cell to the last cell in the row? CreateRange(currentRange, get_range(currentRange.Row + sheet.Columns.Count.ToString())) ? Perhaps there is a better solution.
How to get a set of cells in this range that is not empty? .SpecialCells(xlCellTypeConstants | xlCellTypeFormulas) will not work, for example, if it is not found, .SpecialCells(xlCellTypeConstants) will throw an exception: no cells were found.
Kenny source share