The purpose of the below code is to number rows 6 to rowCount from 1 to rowCount in numerical order in col B. When the user inserts a row, the numbers automatically adjust. For example, if the user inserts a new row between rows 6 and 7, the new row is numbered 7 in col B, the previous row 7 is renumbered 8, and the remaining rows are renumbered 9 to rowCount. This works fine until rowCount >= 100. Then when the user inserts a new row, the program crashes. Why? What's so special about 100 and above? Is there a better method for auto re-renumbering the rows when the user inserts a new row?
Private Sub Worksheet_change(ByVal target As Range)
Dim i As Long, rowCount As Long
rowCount = UsedRange.Rows.Count
For i = 6 To rowCount
If Me.Cells(i, 2) <> i - 5 Then
Me.Cells(i, 2) = i - 5
End If
Next