Run-time error 7 - Out of Memory when trying to use RemoveDuplicates

Inzuri

New Member
Joined
Dec 28, 2012
Messages
33
I have a macro that I'm putting together step by step, and I've hit a roadblock. The basics to this point are to open a file from our internal network, copy all of the information, and paste the values into the macro workbook. It then moves a column in that spreadsheet, copies the values of that column, pastes them on a different spreadsheet in the workbook, and removes the duplicates. If I do these steps individually without the macro, everything works fine. Running the macro though, I get the Out of Memory error at the line highlighted below. I've rebooted, closed all open programs except for this workbook, everything I can think of. I'm using Excel 2010 on a Windows 7 laptop with 8GB of RAM installed, 5.5GB available according to the Resource Monitor. Any assistance on how to get around this error would be appreciated. Thanks!

Code:
Sub Import1()

    Application.DisplayAlerts = False
    Application.EnableEvents = False
    Application.ScreenUpdating = False
    Application.Calculation = xlCalculationManual

    Dim LR As String
   
    Workbooks.Open ("filepath\filename.xlsx")
    Cells.Copy
    Windows("Deal Import.xlsm").Activate
    Sheets("Deal Copy").Activate
    Cells.PasteSpecial (xlPasteValues)
    Columns("P:P").Cut
    Columns("A:A").Insert Shift:=xlToRight
    Application.CutCopyMode = False
    Workbooks("filename.xlsx").Close Save = False

    LR = Range("B10000").End(xlUp).Row

    Range("A1").Value = "CRM Deal Name"
    Range("A2").Select
    ActiveCell.Formula = "=CONCATENATE(RC[1],"" "",RC[4],"" Deal #"",RC[3])"
    ActiveCell.Copy
    Range("A2:A" & LR).PasteSpecial (xlPasteFormulas)
    Cells.Copy
    Cells.PasteSpecial (xlPasteValues)
    Application.CutCopyMode = False
    Range("A1").Select
    

    Range("A2:A" & LR).Copy
    Sheets("Formulas").Activate
    Range("A4").PasteSpecial (xlPasteValues)
    Application.CutCopyMode = False
    LR = Range("A10000").End(xlUp).Row
    Range("A4:A" & LR).Sort key1:=Range("A4"), order1:=xlAscending
    Range("A4:A" & LR).RemoveDuplicates Columns = 1, Header = xlNo

    
    Application.DisplayAlerts = True
    Application.EnableEvents = True
    Application.ScreenUpdating = True
    Application.Calculation = xlCalculationAutomatic

End Sub
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
My apologies.. The line in question is:

Range("A4:A" & LR).RemoveDuplicates Columns = 1, Header = xlNo
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,388
Members
448,957
Latest member
Hat4Life

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