Add new row at the top, rather than the bottom

bsnow

New Member
Joined
Mar 29, 2022
Messages
10
Office Version
  1. 365
Platform
  1. Windows
Hi guys

I'm trying to tweak my VBA code so that it adds a new row at the top, rather than the bottom (most recent row entries display first).

The code I'm using currently is:

Private Sub Button1_Click()
ActiveSheet.ListObjects("Table2").ListRows.Add AlwaysInsert:=True
End Sub


Does anyone have any suggestions to teak the code so it displays the newest row first (row 2) and pushes the other rows down every time a row is added?

Cheers guys!
 

Attachments

  • Excel.JPG
    Excel.JPG
    104.6 KB · Views: 15

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
How about
VBA Code:
Private Sub Button1_Click()
     ActiveSheet.ListObjects("Table2").ListRows.Add 1, True
End Sub
 
Upvote 0
Hi Fluff - thank you for that.

How can I stop the newly added top row from taking on the properties of the header row (i.e. black fill etc.)?
 
Upvote 0
It doesn't do that for me. It uses the data range format
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,601
Messages
6,120,462
Members
448,965
Latest member
grijken

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