help with vba to resize table more than one row

Liz_I3

Well-known Member
Joined
Dec 30, 2002
Messages
647
Office Version
  1. 2016
Platform
  1. Windows
Hi
my below code work to insert one new row to my table. How would I modify it to insert more than one row? Exampel 25


Thanks
L

Sub CheckRows()

Range("a5000").Select
Selection.End(xlUp).Select
Range(Selection, Selection.End(xlUp)).Select

If Selection.Rows.Count < 10 Then

Selection.ListObject.ListRows.Add AlwaysInsert:=True

Else
Exit Sub
End If

End Sub
 

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.
This is NOT tested, Try
Code:
Sub CheckRows()
  Range("a5000").Select
  Selection.End(xlUp).Select
  Range(Selection, Selection.End(xlUp)).Select
  If Selection.Rows.Count < 10 Then
  
  For x = 1 To 10 - Selection.Rows.Count
    Selection.ListObject.ListRows.Add AlwaysInsert:=True
  Next x
  
  Else
    Exit Sub
  End If
End Sub
 
Upvote 0
Thanks I will give it a try. Would you know is there a way to speed up the insert process. We are entering data into the table from a userform. The table will automaticly add a new row but it takes at lease a minute or two (feels like 5) when you submit. At times we submit 3 rows of data at a time. I have it on manual calculation and screen updates set to false.

So I make the table down to about 500 rows, then created a test to say if less that 10 rows left insert, but I would want at least another 200 rows, which I think is going to be very very slow.

My alternative is to just have a message box to contact supervisor to resize the table

Thanks
L
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,756
Members
452,940
Latest member
rootytrip

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