Recorded Macro Clean Up

hydemegan

New Member
Joined
May 7, 2018
Messages
1
Hello!

I have recorded a macro that was working fine, but now all of a sudden it is telling me I don't have enough memory. If I end the macro, and run again, it works, but I would prefer it work the first time. I've read some articles stating I need to remove the .Select from the code, but I am new to using VBA and am not quite sure how to do this. Can someone please help? Code is as follows:

Code:
Sub CopytoPasteSheet()
'
' CopytoPasteSheet Macro
'


'
    Range("C4:D11").Select
    Selection.Copy
    Sheets("Paste Sheet").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    With Selection
        .HorizontalAlignment = xlLeft
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Sheets("Calculator").Select
    Range("G4:H10").Select
    Selection.Copy
    Sheets("Paste Sheet").Select
    Range("A11").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Sheets("Calculator").Select
    Range("E13:F16").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Paste Sheet").Select
    Range("A19").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Sheets("Calculator").Select
    Range("D18:G22").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Paste Sheet").Select
    Range("A25").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    With Selection
        .HorizontalAlignment = xlLeft
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Range("A19:B23").Select
    With Selection
        .HorizontalAlignment = xlLeft
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Range("A11:B17").Select
    With Selection
        .HorizontalAlignment = xlLeft
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
End Sub
Sub ClearCopyPasteSheet()
'
' ClearCopyPasteSheet Macro
'


'
    Sheets("Paste Sheet").Select
    Cells.Select
    Selection.Delete Shift:=xlUp
    Sheets("Calculator").Select
End Sub
Sub CopyPasteCombine()
'
' CopyPasteCombine Macro
'


'
    Application.Run "'Tangible Benefit Calculator v6.xlsm'!CopytoPasteSheet"
    Application.Run "'Tangible Benefit Calculator v6.xlsm'!TestNotePad"
End Sub
Sub ClearCombine()
'
' ClearCombine Macro
'


'
    Application.Run "'Tangible Benefit Calculator v6.xlsm'!Clearcells"
    Application.Run "'Tangible Benefit Calculator v6.xlsm'!ClearCopyPasteSheet"
End Sub
 
Last edited by a moderator:

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,223,912
Messages
6,175,346
Members
452,638
Latest member
Oluwabukunmi

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