Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Insert new row after hitting enter

I would like to write VBA code that basically inserts a
row in a range after someone fills in a cell and hits
enter. For example, if my range is row1:row4, and someone
enters data in row1, a new row is inserted for row2 after
entry. I have created a a worksheet that is sectioned of
into several categories and I do not want to show
numberous rows unless data entry is required -- i.e., the
section grows the more rows someone enters. Any help is
appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Insert new row after hitting enter

right click on sheet tabview codeinsert thissave
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address < "$A$1" Then Exit Sub
Target.Offset(1).Rows.Insert
End Sub

"Jeff" wrote in message
...
I would like to write VBA code that basically inserts a
row in a range after someone fills in a cell and hits
enter. For example, if my range is row1:row4, and someone
enters data in row1, a new row is inserted for row2 after
entry. I have created a a worksheet that is sectioned of
into several categories and I do not want to show
numberous rows unless data entry is required -- i.e., the
section grows the more rows someone enters. Any help is
appreciated.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default Insert new row after hitting enter

Jeff,

The following code in the worksheet module (not a standard module)
will insert a row whenever data is entered into any cell.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Rows(Target.Row + 1).EntireRow.Insert
End Sub

You can use an If statement to restrict it to fire if data is entered into a
specific column:

If Target.Column = 5 Then
Rows(Target.Row + 1).EntireRow.Insert
End If
with this your user can enter into columns A to E and only after an entry in
E will the new row be inserted.

You can also add to the If statement to make sure that a blank row doesn't
already exist...

Target is the cell that was was changed.
The macro is an event macro...

--
sb
"Jeff" wrote in message
...
I would like to write VBA code that basically inserts a
row in a range after someone fills in a cell and hits
enter. For example, if my range is row1:row4, and someone
enters data in row1, a new row is inserted for row2 after
entry. I have created a a worksheet that is sectioned of
into several categories and I do not want to show
numberous rows unless data entry is required -- i.e., the
section grows the more rows someone enters. Any help is
appreciated.



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
value changes after hitting Tab or Enter button Jose Esteves Excel Discussion (Misc queries) 2 January 27th 10 08:59 PM
numbers appear different after hitting enter cb New Users to Excel 3 March 27th 08 10:46 PM
If I type in 3, I get .003 after hitting enter. All .xls files. Stu Excel Discussion (Misc queries) 2 May 10th 06 02:04 PM
What does hitting Ctrl + Shift + Enter to enter a formula do??? Help a n00b out. qwopzxnm Excel Worksheet Functions 2 October 20th 05 09:06 PM
how to insert row automatically after hitting enter at the end of. Ali Excel Worksheet Functions 1 November 11th 04 07:24 AM


All times are GMT +1. The time now is 11:31 PM.

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

About Us

"It's about Microsoft Excel"