Spreadsheet slow to add new lines

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
2,352
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

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
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,214,649
Messages
6,120,728
Members
448,987
Latest member
marion_davis

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