Hi,
I'm trying to insert a row below the active row when the value of a cell changes. I tried it on different ways and everytime with the same result and error.
Excel inserts 90 rows (instead of 1) and after that, Excel crashes everytime with the following error:
The code I'm using
I have replace "Target.Entire......." with rows(activecell.row) but without any success.
Can someone help me with this problem?
Cheers,
Jan
I'm trying to insert a row below the active row when the value of a cell changes. I tried it on different ways and everytime with the same result and error.
Excel inserts 90 rows (instead of 1) and after that, Excel crashes everytime with the following error:
Run-time error '-2147417848 (80010108)':
Method "Insert"of object "Range" failed
The code I'm using
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lngLR As Long
Dim sht As Worksheet
Set sht = ActiveWorkbook.ActiveSheet
lngLR = sht.Cells(Rows.Count, "A").End(xlUp).Row
If Not Intersect(Target, sht.Range("C2:C" & lngLR)) Is Nothing Then
Target.Offset(1, 0).EntireRow.Insert
End If
End Sub
I have replace "Target.Entire......." with rows(activecell.row) but without any success.
Can someone help me with this problem?
Cheers,
Jan