J
Jeff
I have a spreadsheet that is divided into three sub
sections: 1)Rows(2:5), 2) Rows(8:11), and 3)Rows(14:17).
I would like to create the ability for row insertion after
data is entered within any of the rows in the
subsections. I have the following code:
Private Sub Worksheet_Change(ByVal Target As Range)
Static RowCounter As Long
If Target.Row = 3 + RowCounter Then
Rows(Target.Row+1).EntireRow.Insert
RowCounter = RowCounter + 1
End If
The problem with this code is the fact that if I press
ener in a row in section 1, then go to section 3 and press
enter, I am in trouble. Is there a fix where I can reset
the counter or do I need to take a different approach?
sections: 1)Rows(2:5), 2) Rows(8:11), and 3)Rows(14:17).
I would like to create the ability for row insertion after
data is entered within any of the rows in the
subsections. I have the following code:
Private Sub Worksheet_Change(ByVal Target As Range)
Static RowCounter As Long
If Target.Row = 3 + RowCounter Then
Rows(Target.Row+1).EntireRow.Insert
RowCounter = RowCounter + 1
End If
The problem with this code is the fact that if I press
ener in a row in section 1, then go to section 3 and press
enter, I am in trouble. Is there a fix where I can reset
the counter or do I need to take a different approach?