#### helpexcel

##### Well-known Member
I'm using the following code on my worksheet page and want to know how I can expand this so that if I insert data in row 2 it will add another line as shown.

Call Ghostbusters
End If

Call Ghostbusters
End If

### Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

#### dave3009

##### Well-known Member
Hi, try something like this

Code:
``````Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A1:B1")) Is Nothing Then
Call Ghostbusters
End If
End Sub``````

#### helpexcel

##### Well-known Member
Sorry i meant that the data would be added to row 2. I updated the code to reflect this, but i think it is now preventing me from using the code that adds a row. Is there a way to say Range (A1:LR)
and the define LR. So that it would look and A1 and then count every row under that, that has a value in A

#### dave3009

##### Well-known Member
Code:
``````Private Sub Worksheet_Change(ByVal Target As Range)
Dim lstRow As Long
lstRow = Range("A" & Rows.Count).End(xlUp).Row
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A1:A" & lstRow)) Is Nothing Then
Call Ghostbusters
End If
End Sub``````

OR

Code:
``````Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("A:A")) Is Nothing Then
Call Ghostbusters
End If
End Sub``````

Replies
16
Views
131
Replies
3
Views
107
Replies
4
Views
85
Replies
1
Views
44
Replies
4
Views
46

1,127,261
Messages
5,623,692
Members
415,983
Latest member
MusicMan

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back