@Alvord, Timothy, Welcome to Microsoft Q&A, you could try to use Range.SpecialCells(XlCellType, Object) Method to get filtered rows.
Here is a code example you could refer to.
Excel.Application app=new Excel.Application();
Excel.Workbook workbook = app.Workbooks.Open("test.xlsx");
Excel.Worksheet worksheet = workbook.Worksheets[1];
Excel.Range visibleCells = worksheet.UsedRange.SpecialCells(
Excel.XlCellType.xlCellTypeVisible,
Type.Missing);
Excel.Range visibleCells = worksheet.UsedRange.SpecialCells(
Excel.XlCellType.xlCellTypeVisible,
Type.Missing);
foreach (Excel.Range area in visibleCells.Areas)
{
foreach (Excel.Range row in area.Rows)
{
if (row.Row!=935)
{
Console.WriteLine(row.Row);
}
else
{
break;
}
}
}
workbook.Close();
Based on my test. it could produce the correct row's count.
If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.