Automatically insert new row at top of table

milestogo

New Member
Joined
Feb 19, 2025
Messages
2
Office Version
  1. 2021
Platform
  1. MacOS
I have a table which I would like to be able to fill from the top, putting recent entries first. I am trying to make it so when data is added to cell E2, a new row is added in A2-F2. There is another data table next to the one in question so I would like if the insert didn't span across the whole sheet. I have tried recording a macro, but I would like the row to be inserted automatically without having to push a button.
 
Ok, I managed to get i working how I wanted, and it put the active cell back in position to enter new data.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$E$2" Then

Range("A2:F2").Select
Selection.ListObject.ListRows.Add (1)
Range("A2").Select

End If
End Sub
 
Upvote 0
Try to use worksheet module (right click on tab name then select ViewCode, paste this code into)

VBA Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 5 Or Target.Row <> 2 Then Exit Sub
Application.EnableEvents = False
Range("A2:F2").Select
Selection.ListObject.ListRows.Add (1)
Range("E2").Select
Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,226,798
Messages
6,193,065
Members
453,773
Latest member
bclever07

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top