Auto add new row

  • Thread starter Thread starter IT
  • Start date Start date
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).
 
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
 
Back
Top