VBA assist inserting rows with text before and after in same column that insert depend son

elmar007

Board Regular
Joined
Nov 9, 2012
Messages
86
Hi all

I am using the following code:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Column <> 9 Or Target.Count <> 1 Then Exit Sub
If Target.Row = Cells(65536, 9).End(xlUp).Row Then _
Target.Offset(1, 0).EntireRow.Insert
End Sub

it allows me to insert a blank row after I input in Column I.

However if I have anything in column I after where I want to input it does not work

ie. If I input data in cell I2 (and there is no other data in column I down fron I2) it automatically generates a new row 3 (this is what I want it to do).

However if I already had data in cell I7 then I inputted into cell I2 it would not generate my new row 3.

Any advise please on modifying my code

RM
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Try:
Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    If Target.Column <> 9 Or Target.Count <> 1 Then Exit Sub
    Target.Offset(1).EntireRow.Insert
End Sub
 
Upvote 0
Nice one JDI

That is a much cleaner code

Ok now it gets more complicated

How do I expand code to include Col J & Col K ie. 10 and 11?

These rows are completed after Col I. if there are enough rows put in from col I then no need to add rows

cheers
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,264
Messages
6,171,081
Members
452,377
Latest member
bradfordsam

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top