Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default VBA Code- Row Insertion

I have broken up a spreadsheet into several sections. In
each section, I would like to enter code that would allow
the user, once to the last row of each section, to
automatically insert another row(s). I have attempted to
write the code (see below) for this, but there is one
problem. Once one row is entered, the new row that is
created does not allow for another row to be created, i.e.
if the code is referenced to row 3 and a new row is
inserted (row 4), once the user hits enter in row 4, a new
row cannot be created.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 3 Then
Rows(Target.Row + 1).EntireRow.Insert
End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default VBA Code- Row Insertion

Jeff

maybe this would do it:

If Target.Row = 3 Then

I don't know how this would affect other "sections"

Regards

Trevor


"Jeff" wrote in message
...
I have broken up a spreadsheet into several sections. In
each section, I would like to enter code that would allow
the user, once to the last row of each section, to
automatically insert another row(s). I have attempted to
write the code (see below) for this, but there is one
problem. Once one row is entered, the new row that is
created does not allow for another row to be created, i.e.
if the code is referenced to row 3 and a new row is
inserted (row 4), once the user hits enter in row 4, a new
row cannot be created.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 3 Then
Rows(Target.Row + 1).EntireRow.Insert
End If
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default VBA Code- Row Insertion

Trevor,
Thank you for your response, but I believe this would
allow row insertion for every row after 3, but would not
work for multiple sections (i.e. i do not want certain
rows after 3 to allow for insertion). Anyone else have a
solution.
-----Original Message-----
Jeff

maybe this would do it:

If Target.Row = 3 Then

I don't know how this would affect other "sections"

Regards

Trevor


"Jeff" wrote in

message
...
I have broken up a spreadsheet into several sections.

In
each section, I would like to enter code that would

allow
the user, once to the last row of each section, to
automatically insert another row(s). I have attempted

to
write the code (see below) for this, but there is one
problem. Once one row is entered, the new row that is
created does not allow for another row to be created,

i.e.
if the code is referenced to row 3 and a new row is
inserted (row 4), once the user hits enter in row 4, a

new
row cannot be created.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 3 Then
Rows(Target.Row + 1).EntireRow.Insert
End If
End Sub



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default VBA Code- Row Insertion

OK, give this a try:

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

End Sub

Regards

Trevor


wrote in message
...
Trevor,
Thank you for your response, but I believe this would
allow row insertion for every row after 3, but would not
work for multiple sections (i.e. i do not want certain
rows after 3 to allow for insertion). Anyone else have a
solution.
-----Original Message-----
Jeff

maybe this would do it:

If Target.Row = 3 Then

I don't know how this would affect other "sections"

Regards

Trevor


"Jeff" wrote in

message
...
I have broken up a spreadsheet into several sections.

In
each section, I would like to enter code that would

allow
the user, once to the last row of each section, to
automatically insert another row(s). I have attempted

to
write the code (see below) for this, but there is one
problem. Once one row is entered, the new row that is
created does not allow for another row to be created,

i.e.
if the code is referenced to row 3 and a new row is
inserted (row 4), once the user hits enter in row 4, a

new
row cannot be created.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 3 Then
Rows(Target.Row + 1).EntireRow.Insert
End If
End Sub



.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Row Insertion mlockman Excel Discussion (Misc queries) 0 April 17th 09 03:33 PM
Data insertion tariq Excel Worksheet Functions 1 September 12th 07 01:43 PM
Automatic row insertion PURVIANCE Excel Discussion (Misc queries) 1 December 6th 06 08:59 PM
Rows Insertion b166er Excel Worksheet Functions 3 August 2nd 06 06:52 PM
Rows Insertion b166er Excel Worksheet Functions 1 June 22nd 06 04:41 PM


All times are GMT +1. The time now is 12:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"