CERipkenJr
New Member
- Joined
- May 22, 2017
- Messages
- 9
Hi there.
I have used the following code (copied from the Internet) with success - it inserts rows into my spreadsheet based on a number from another cell - perfect:
[TABLE="width: 448"]
<tbody>[TR]
[TD="colspan: 6"]Private Sub Worksheet_Change(ByVal Target As Range)[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 5"] If Target.AddressLocal = "$P$5" Then[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 3"] Dim i As Integer[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 4"] For i = 1 To Target.Value[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 5"] Range("2:2").EntireRow.Insert[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 2"] Next i[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 2"] End If[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]End Sub
How would I go about altering this code to add text to the row(s) created? (i.e. I need all inserted rows to say "Option Rent" in a particular cell of the added row(s).
Thanks a million.[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
I have used the following code (copied from the Internet) with success - it inserts rows into my spreadsheet based on a number from another cell - perfect:
[TABLE="width: 448"]
<tbody>[TR]
[TD="colspan: 6"]Private Sub Worksheet_Change(ByVal Target As Range)[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 5"] If Target.AddressLocal = "$P$5" Then[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 3"] Dim i As Integer[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 4"] For i = 1 To Target.Value[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 5"] Range("2:2").EntireRow.Insert[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 2"] Next i[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="colspan: 2"] End If[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]End Sub
How would I go about altering this code to add text to the row(s) created? (i.e. I need all inserted rows to say "Option Rent" in a particular cell of the added row(s).
Thanks a million.[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Last edited: