My first row has X filled cells counting from A1. I want to get a reference to the second to the last cell (so if C1 is the last filled, I want B1, if U1 is the last filled I want T1).
Here’s corresponding VBA code:
Function GetSecondToLast() As Range
Set GetSecondToLast = Range(“A1”).End(xlToRight).Offset(, -1)
End Function
I know that I need to handle the special cases (A1 or B1 is empty), but I know how to do those without overly complicating this. I can assume here there’s no empty cells in between (like “A1 has value, B1 does not and C1 has value” kind of case isn’t necessarily relevant here).
So how to do this in Aspose.Cells with C#?