rhaney

Board Regular
Joined
Sep 27, 2009
Messages
64
This code from the Excel Macro Recorder works, and does what I need, but it is not efficient. Can someone please help me and make it more efficient?
Thank you in advance for your assistance!
Robert

Code:
Sub Macro1()
'
' Macro1 Macro
'Round 1 Topic 1 Question $100
'
'
    Sheets("Setup Page").Select
    Range("E11:AA12").Select
    Selection.Copy
    Sheets("Game Page Round 1").Select
    Range("G40:AC41").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Sheets("Setup Page").Select
    Range("D11").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Game Page Round 1").Select
    Range("A40").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("A41").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Sheets("Setup Page").Select
    Range("AC11").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Game Page Round 1").Select
    Range("P42").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Sheets("Game Page Round 1").Select
    ActiveSheet.Shapes.Range(Array("Rounded Rectangle 61")).Select
    Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = ""
    Range("A1").Select
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.
You could change the red portions to each following blue section.

Code:
Sub Macro1()
'
' Macro1 Macro
'Round 1 Topic 1 Question $100
'
'
    [COLOR=#ff0000]Sheets("Setup Page").Select
    Range("E11:AA12").Select
    Selection.Copy
    Sheets("Game Page Round 1").Select
    Range("G40:AC41").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False[/COLOR]

[COLOR=#0000ff]Sheets("Setup Page").Range("E11:AA12").Copy Sheets("Game Page Round 1").Range("G40:AC41")[/COLOR]

    [COLOR=#ff0000]Sheets("Setup Page").Select
    Range("D11").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Game Page Round 1").Select
    Range("A40").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

[/COLOR][COLOR=#0000ff]Sheets("Setup Page").Range("D11").Copy Sheets("Game Page Round 1").Range("A40")
[/COLOR]
[COLOR=#FF0000]    Range("A41").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False[/COLOR]

[COLOR=#0000ff]Sheets("Setup Page").Range("D11").Copy Sheets("Game Page Round 1").Range("A41")[/COLOR]

    [COLOR=#ff0000]Sheets("Setup Page").Select
    Range("AC11").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Game Page Round 1").Select
    Range("P42").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False[/COLOR]
[COLOR=#0000ff]
Sheets("Setup Page").Range("AC11").Copy Sheets("Game Page Round 1").Range("P42")[/COLOR]

    Sheets("Game Page Round 1").Select
    ActiveSheet.Shapes.Range(Array("Rounded Rectangle 61")).Select
    Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = ""
    Range("A1").Select
End Sub

I wasn't sure what you are doing with A41, so I left it alone.

Edit: Copying D11 into both A40 and A41?
 
Last edited:
Upvote 0
Give this a try. I've only begun editing Recorder's VBA so be wary.

Just one thought though, should you have both A40 and A41 receiving the same data from the D11 cell just above them?

Code:
Sub Macro1()
        '
        ' Macro1 Macro
        'Round 1 Topic 1 Question $100
        '
        '
            Sheets("Setup Page").Select
            Range("E11:AA12").Copy
            Sheets("Game Page Round 1").Select
            Range("G40:AC41").PasteSpecial
                
            Sheets("Setup Page").Select
            [COLOR=#ff0000]Range("D11").Copy[/COLOR]
            Sheets("Game Page Round 1").Select
            [COLOR=#ff0000]Range("A40").PasteSpecial
            Range("A41").PasteSpecial[/COLOR]
            
            Sheets("Setup Page").Select
            Range("AC11").Copy
            Sheets("Game Page Round 1").Select
            Range("P42").PasteSpecial
            Sheets("Game Page Round 1").Select
            ActiveSheet.Shapes.Range(Array("Rounded Rectangle 61")).ShapeRange(1).TextFrame2.TextRange.Characters.Text = ""
            Range("A1").Select
        End Sub
 
Upvote 0
I did one for you. See the commented link if not clear.
Code:
Sub Test()
  Application.ScreenUpdating = False
  Application.EnableEvents = False
  Application.Calculation = xlCalculationManual

  'Sheets("Setup Page").Select
  'Range("E11:AA12").Select
  'Selection.Copy
  'Sheets("Game Page Round 1").Select
  'Range("G40:AC41").Select
  'Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
      :=False, Transpose:=False
      
  'Beyond Macro Recorder: http://www.tushar-mehta.com/excel/vba/beyond_the_macro_recorder/index.htm
  Sheets("Setup Page").Range("E11:AA12").Copy
  Sheets("Game Page Round 1").Range("G40:AC41").PasteSpecial _
    Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
  '....
  
  
  Application.CutCopyMode = False
  Application.ScreenUpdating = True
  Application.EnableEvents = True
  Application.Calculation = xlCalculationAutomatic
End Sub
 
Upvote 0
How long is your code taking?
I don't think cleaning up the code will make much difference.
Code:
Sub FT()
Dim sp As Worksheet: Set sp = Sheets("Setup Page")
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
With Sheets("Game Page Round 1")
    .[G40:AC41] = sp.[E11:AA12].Value
    .[A40] = sp.[D11].Value
    .[A41] = sp.[D11].Value
    .[P42] = sp.[AC11].Value
    .Select
End With
ActiveSheet.Shapes.Range(Array("Rounded Rectangle 61")).Select
Selection.ShapeRange(1).TextFrame2.TextRange.Characters.Text = ""
Range("A1").Select
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,267
Members
449,075
Latest member
staticfluids

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