excelvbarow

Row numbers not updated after deleting entire rows


I am making an Excel macro to filter things, and therefore delete unnecessary rows. First I create a range of irrelevant cells (by making the union of them), and after that I delete the whole row for the given range.

deleteRng.EntireRow.Delete

So if I have a worksheet with 100 rows and the rows from 40 to 60 are irrelevant, that range is deleted and the rows from 60 to 100 shifted up, so totally I got 80 rows counted from 1 to 80. This works perfectly most of time, but with some special workbooks the row numbers not updated after the deletion, therefore in the previous example the rows counted like 1...40,61...100.

SO33965610 question example

Is there a workbook related setting which do this or what else could be the problem?


Solution

  • That gap between the numbers means that the rows are hidden. You can show them by highlighting both the rows above and below (15 and 19 in your example) and right clicking and selecting Unhide. Are there perhaps hidden rows already there when you initiate your script?