Simple Macro was running fine, and then got super slow

Abha23

New Member
Joined
Jan 29, 2020
Messages
3
Office Version
  1. 2019
Platform
  1. MacOS
Hi everyone,

I'm hoping I can get some help in optimizing my macro. It essentially:

1. Copies a row from one sheet ("Update")
2. Inserts a row into another sheet ("Overall") which has the master table.
3. Copies the row from the Update sheet into the inserted row of the master table.

It doesn't have any logic beyond that, so I'm confused as to why it's moving so slowly - it takes around 5-6 seconds to run now, compared to the almost-instant speed at first.

VBA Code:
Sub UpdateWithoutSort()
'
' UpdateWithoutSort Macro
''
    Application.Calculation = xlCalculationManual
    Application.ScreenUpdating = False
    Application.DisplayStatusBar = False
    Sheets(“Overall”).Select
    Range(“B6:O6").Select
    Selection.ListObject.ListRows.Add (1)
    Sheets(“Update”).Select
    Range(“B15:M15").Select
    Selection.Copy
    Sheets(“Overall”).Select
    Range(“B6").Select
    Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
        xlNone, SkipBlanks:=False, Transpose:=False
    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True
    Application.DisplayStatusBar = True
End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
How about
VBA Code:
Sub UpdateWithoutSort()
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
With Sheets("Overall")
    .Range("B6:O6").ListObject.ListRows.Add (1)
    With Sheets("Update")
        .Range("B15:M15").Copy
    End With
    .PasteSpecial Paste:=xlPasteValuesAndNumberFormats
End With
Application.CutCopyMode = False
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Application.DisplayStatusBar = True
End Sub
 
Upvote 0
Thanks for helping @VBE313 - this gives me an error (run-time error '1004' )at the piece below:

.PasteSpecial Paste:=xlPasteValuesAndNumberFormats

Is there anything I'm missing?
 
Upvote 0
Thanks for helping @VBE313 - this gives me an error (run-time error '1004' )at the piece below:

.PasteSpecial Paste:=xlPasteValuesAndNumberFormats

Is there anything I'm missing?
Sorry,

VBA Code:
Sub UpdateWithoutSort()
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
With Sheets("Overall")
    .Range("B6:O6").ListObject.ListRows.Add (1)
    With Sheets("Update")
        .Range("B15:M15").Copy
    End With
    .PasteSpecial
End With
Application.CutCopyMode = False
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Application.DisplayStatusBar = True
End Sub
 
Upvote 0
This helped quite a bit, thanks so much! It's not instantaneous, do you know if the reason is because the main table ("Overall" tab) getting larger as more and more rows are inserted into it?
 
Upvote 0
This helped quite a bit, thanks so much! It's not instantaneous, do you know if the reason is because the main table ("Overall" tab) getting larger as more and more rows are inserted into it?
It could mean many things. I would have to seethe document to help you further.
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,823
Members
449,049
Latest member
cybersurfer5000

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