Speed up my VBA. Small code

ItalianPlatinum

Well-known Member
Joined
Mar 23, 2017
Messages
793
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello - I believe my VBA is clocking because of my large dataset and me copying/pasting the below. is anyone able to assist of how to optimize it?
VBA Code:
Application.Run "'_ALL .xlsm'!ALLV"
Application.ScreenUpdating = False
lr = Range("A11").End(xlDown).row
Range("A11:X" & lr).Copy
With Sheets("Pre").Range("A" & rows.count).End(xlUp).Offset(1)
    .PasteSpecial Paste:=xlPasteValues
    .PasteSpecial Paste:=xlPasteFormats
End With
Application.CutCopyMode = False
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
If you replace the code that you are showing with the code below and run it, what does the message box state?
VBA Code:
    Application.Run "'_ALL .xlsm'!ALLV"
    Application.ScreenUpdating = False
    Dim t As Double
    t = Timer
    lr = Range("A11").End(xlDown).Row
    Range("A11:X" & lr).Copy
    With Sheets("Pre").Range("A" & Rows.Count).End(xlUp).Offset(1)
        .PasteSpecial Paste:=xlPasteValues
        .PasteSpecial Paste:=xlPasteFormats
    End With

    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    MsgBox "Code took " & Format(Timer - t, "0.00 secs")
 
Upvote 0
Solution
If you replace the code that you are showing with the code below and run it, what does the message box state?
VBA Code:
    Application.Run "'_ALL .xlsm'!ALLV"
    Application.ScreenUpdating = False
    Dim t As Double
    t = Timer
    lr = Range("A11").End(xlDown).Row
    Range("A11:X" & lr).Copy
    With Sheets("Pre").Range("A" & Rows.Count).End(xlUp).Offset(1)
        .PasteSpecial Paste:=xlPasteValues
        .PasteSpecial Paste:=xlPasteFormats
    End With

    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    MsgBox "Code took " & Format(Timer - t, "0.00 secs")
darn only 3.61 seconds. the file _ALL ends up being 200,000 kb file when i save and open it multiple times. i suppose could be that. alright then
 
Upvote 0
You're welcome (although not of much help if you can't access the other code).
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,684
Members
449,116
Latest member
HypnoFant

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