We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Next used cell in a column Selection.End(xlDown).Select

Hello,
I need to get the number of the next row not empty in the column, in VBA I could do something like:
Selection.End(xlDown).Select;
and then get the row of the selected cell.
How can I do that using XlsIO component?

Thanks a lot.

3 Replies

SR Sudha Ramachandran Syncfusion Team February 18, 2015 10:46 AM UTC

Hi Sam,

Thank you for using Syncfusion products.

XlsIO does not have direct methods to achieve the functionalities like ‘Selection.End(xlDown).Select’. But, this can be achieved through a workaround and we have shared the workaround sample in the following link. Kindly try this and let us know if this helps.

Sample Link: http://www.syncfusion.com/downloads/support/directtrac/118257/XlsIOSample938581989.zip

Please let us know if you have any queries.

Regards,

Sudha R



NI Nivas July 15, 2022 06:22 AM UTC

Hi, 

I'm facing the same issue but I'm not able to download the sample solution that you've provided. Can you please give me the access for the above sample solution.

Thanks, 

Nivas.



RS Ramya Sivakumar Syncfusion Team July 18, 2022 12:57 PM UTC

Hi Nivas,


Greetings from Syncfusion.


We have prepared the sample to fetch the last cell. Kindly try this and let us know if it helps.


Code snippet:

FileStream inputStream = new FileStream("Sample.xlsx", FileMode.Open);

IWorkbook workbook = excelEngine.Excel.Workbooks.Open(inputStream);

IWorksheet worksheet = workbook.Worksheets[0];              

 

IRange cell = worksheet.Range["A1"];

IRange usedRange = worksheet.UsedRange;

var lastcell = "";

int col = cell.Column;

int lastRow;

 

for (int row = 1;  row <= usedRange.LastRow; row++)

{

     if (!worksheet[row, col].IsBlank)

     {

          lastcell = worksheet[row, col].AddressLocal;

          lastRow = row;

     }

}



The complete sample can be downloaded from the below link.

Sample link - https://www.syncfusion.com/downloads/support/directtrac/general/ze/F-118257-1179841992


Regards,

Ramya


Loader.
Live Chat Icon For mobile
Up arrow icon