Macro runs slow on superior computer

mlk11

New Member
Joined
Feb 22, 2017
Messages
9
I have a macro, it's not an especially well written macro, but it works. It involves a lot of copy and pasting within a spreadsheet with lots of necessary COUNTIFand INDEX/MATCH formulas.

I run the macro at work and at home on my new computer.

The thing is, this macro runs, literally, twice as fast on my inferior computer at work. I've added in a timer to the macro to measure performance to back this up.

Work PC - Intel i3-3220 3.3GHz - 2 cores - 4GB RAM.
Home PC - AMD Ryzen 1700X 3.8 GHz - 16 cores - 16GB RAM.

I'm so confused, how can a far inferior computer be so much quicker? I should also point out I'm running Excel 2013 on both computers too, x64 version at home, x32 at work.

I've even overclocked my home computer, and checked the Advanced settings within Excel (Enable mutli threaded Calculation).

Is my problem with the code? (I can't see how it would be) How does one get the most out of processing power within Excel?

Many thanks on any thoughts or comments.

Code:
Sub Home()

Sheets("Home Raffle").Select

    Range("AO1:AO2").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("AP1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

StartHome:

Sheets("Home Raffle").Select

    Columns("AJ:AK").Select
    Selection.ClearContents

    Range("AG1:AH1").Select
    Selection.Copy
    Do
    Range("AJ101").Select
    Selection.End(xlUp).Select
    ActiveCell.Offset(1, 0).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
        
    If Sheets("Home Raffle").Range("AH5") > 0.5 Then
    Sheets("Home Raffle").Select
    Columns("AJ:AK").Select
    Selection.ClearContents
    GoTo StartHome
    Else
    'Do Nothing
    End If
        
Loop Until Range("AH3") = "All Picked"

End Sub
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
A few tips to help speed up your code:

1. Physically selecting range slows down your code. You typically do not need to actually select your ranges in order to work with them. You can eliminate a lot of this.
Most anywhere you have one line end in "Select", and the next line begin with "Selection" or "ActiveCell", this two lines can usually be combined together.

2. You can also speed up your code by temporarily shutting off screen updates and automatic calculation until it completes.

I didn't do a full analysis of your code, but I applied the changes up above to your existing code. See if this code works and is any faster.
Code:
Sub Home()

    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual

    Sheets("Home Raffle").Select

    Range("AO1:AO2").Copy
    Range("AP1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

StartHome:

    Sheets("Home Raffle").Select

    Columns("AJ:AK").ClearContents

    Range("AG1:AH1").Copy
    
    Do
    
        Range("AJ101").End(xlUp).Offset(1, 0).PasteSpecial _
            Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        
            If Sheets("Home Raffle").Range("AH5") > 0.5 Then
                Sheets("Home Raffle").Select
                Columns("AJ:AK").ClearContents
                GoTo StartHome
            Else
                'Do Nothing
            End If
        
    Loop Until Range("AH3") = "All Picked"

    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True

End Sub
 
Upvote 0
A few tips to help speed up your code:

1. Physically selecting range slows down your code. You typically do not need to actually select your ranges in order to work with them. You can eliminate a lot of this.
Most anywhere you have one line end in "Select", and the next line begin with "Selection" or "ActiveCell", this two lines can usually be combined together.

2. You can also speed up your code by temporarily shutting off screen updates and automatic calculation until it completes.

I didn't do a full analysis of your code, but I applied the changes up above to your existing code. See if this code works and is any faster.
Code:
Sub Home()

    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual

    Sheets("Home Raffle").Select

    Range("AO1:AO2").Copy
    Range("AP1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

StartHome:

    Sheets("Home Raffle").Select

    Columns("AJ:AK").ClearContents

    Range("AG1:AH1").Copy
    
    Do
    
        Range("AJ101").End(xlUp).Offset(1, 0).PasteSpecial _
            Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        
            If Sheets("Home Raffle").Range("AH5") > 0.5 Then
                Sheets("Home Raffle").Select
                Columns("AJ:AK").ClearContents
                GoTo StartHome
            Else
                'Do Nothing
            End If
        
    Loop Until Range("AH3") = "All Picked"

    Application.Calculation = xlCalculationAutomatic
    Application.ScreenUpdating = True

End Sub

Thanks for your advice, much appreciated.

If anyone could offer any insight as to why a 3.8 GHz with 16 cores and 16GB RAM takes twice as long to run the above code compared to a 3.3GHz with 2 cores and 4GB RAM, I'd be grateful.

I partially bought the computer with the hope it would run my more extreme spreadsheets quickly.

Don't have any Anti Viruses running with Excel. Work computer uses Windows 10 whereas my PC is Windows 7?

Is Windows 10 proven to be more efficient with Excel?

Would adding/remove add-ins help?

I'm struggling!
 
Upvote 0
I no expert, on computer performance, but I am willing to bet the the reason lies somewhere in these details:
I should also point out I'm running Excel 2013 on both computers too, x64 version at home, x32 at work.
Work computer uses Windows 10 whereas my PC is Windows 7
 
Last edited:
Upvote 0
I was under the impression 64 bit is faster than 32 bit? and that certain limitations are applied to 32 bit Excel?
 
Upvote 0
I was under the impression 64 bit is faster than 32 bit?
I don't believe that is necessarily always true. I think a lot may depend on your configuration.
I am not sure how well 64 bit works on older version of Windows.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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