Spreadsheet slow to add new lines

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
1,706
My spreadsheet is slow to add a new line through a macro, how could I speed it up?
 

Some videos you may like

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

dpaton05

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

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
19,237
Office Version
  1. 2013
Platform
  1. Windows
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
 

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
1,706

ADVERTISEMENT

I think I found the problem. It seems to go quicker if I delete unnecessary code or unused code in my project.
 

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
19,237
Office Version
  1. 2013
Platform
  1. Windows
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,108,624
Messages
5,523,965
Members
409,547
Latest member
AW2020

This Week's Hot Topics

Top