Spreadsheet slow to add new lines

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
2,373
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
My spreadsheet is slow to add a new line through a macro, how could I speed it up?
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
which macro Dave ??

Here is my code

Code:
Private Sub cmdAddRow_Click()

Dim tbl As ListObject
Dim newRow As ListRow


Set tbl = Worksheets("home").ListObjects("tblCosting")


    'ActiveSheet.Unprotect Password:="npssadmin"

    'add a row at the end of the table
    
    Set newRow = tbl.ListRows.Add
    newRow.Range(28) = 1 'assuming the first column of your table is in Column A. Adjust as necessary
    
End Sub
 
Upvote 0
Works fine for me.....make sure you don't have any sheet macros that are running as well, like a worksheet sekection change event, that could be fired when your code tries to add the new line
 
Upvote 0
I think I found the problem. It seems to go quicker if I delete unnecessary code or unused code in my project.
 
Upvote 0
Yep.....anything that is linked to that sheet via VBA is potentially a problem.
I'm guessing by some of your previous threads, that you have a number of macros in the workbook.
It might be a good time to merge / remove some of your codes wherever possible..

It's easy to lose track of where and what is happening.
 
Upvote 0

Forum statistics

Threads
1,223,606
Messages
6,173,323
Members
452,510
Latest member
RCan29

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