I have the following code:
Excel.Range range = workSheet.UsedRange;
for (rowCount = 2; rowCount <= range.Rows.Count; rowCount++)
{
//Do something here
}
However, I encounter the following problem. If I have the following excel data:
cell1, cell2, cell3
cell4, cell5, cell6
..............cell7
range.Rows.Count will return 3. However, I don’t care about column C – it has some data that is used for drop-down lists within say column 1. How can I get the range.Rows.Count only for columns A and B?
For example:

Assuming there are no blanks in column A, just walk down rows until you hit a blank row using
range.Offset(x,y): (sorry, I’m more fluent with Excel VBA, you’ll have to translate to C#)Or just loop through numerically using
Worksheet.Cells(row,col):Edit: You could also use
Range("A1").End(xlDown)to find the last populated cell of the first column. This should work with your current logic. Something like (I’ll try it in C#):