ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Auto add new row (https://www.excelbanter.com/excel-programming/433743-auto-add-new-row.html)

IT

Auto add new row
 
How setup auto add new row when click the box



Patrick Molloy[_2_]

Auto add new row
 
click what box?

"IT" wrote:

How setup auto add new row when click the box




IT

Auto add new row
 
Sorry ...

My Question as .
I am update data in a field. After my mouse click move next field , the
script will atuo insert new row ( included the formula).

"Patrick Molloy" wrote in message
...
click what box?

"IT" wrote:

How setup auto add new row when click the box






Patrick Molloy[_2_]

Auto add new row
 
ok. here is some code. Right click on the sheet TAB and from the menu list
select 'View Code'
Paste the code into the module that opens.


The assumption is that the table begins at cell E9.
When you enter anything in any cell, the CHANGE event fires. This gets the
location on the bottom right cell (saved as lastrow, lastcolumn) . If the
cell that changes has the same address, then the last row is replicated
down...but not the last cell

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lastRow As Long
Dim lastCol As Long
lastRow = Range("E9").End(xlDown).Row
lastCol = Range("E9").End(xlToRight).Column
If Target.Row = lastRow And Target.Column = lastCol And Target.Count = 1 Then
Range(Cells(lastRow, "E"), Cells(lastRow, lastCol - 1)).Copy
Cells(lastRow + 1, "E").PasteSpecial xlPasteAll
End If
End Sub

"IT" wrote:

Sorry ...

My Question as .
I am update data in a field. After my mouse click move next field , the
script will atuo insert new row ( included the formula).

"Patrick Molloy" wrote in message
...
click what box?

"IT" wrote:

How setup auto add new row when click the box








All times are GMT +1. The time now is 11:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com