ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Error 1004 - Out of Memory (https://www.excelbanter.com/excel-programming/303907-error-1004-out-memory.html)

m4nd4li4

Error 1004 - Out of Memory
 
Hi,

Everytime I run the macro below, I get an "Out of Memory" error. It
occurs at the ActiveSheet.Paste line. Why does this happen and how can
I solve it???

Sub BatchProcessor()
With Application.FileSearch
.NewSearch
.LookIn = "d:\activea\" '(insert proper file directory)
.SearchSubFolders = True
.FileName = "PT*.mea"
.MatchTextExactly = True
.FileType = msoFileTypeAllFiles
If .Execute() 0 Then
' MsgBox "There were " & .FoundFiles.Count & "file(s) found."
For I = 1 To .FoundFiles.Count
Workbooks.Open FileName:=.FoundFiles(I)
With ActiveWorkbook
Columns("A:A").EntireColumn.AutoFit
Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"),
DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(16, 1))
Selection.AutoFilter
Range("B1").Select
Selection.AutoFilter Field:=1, Criteria1:="Dist"
Range("B2:B65536").Select
Selection.NumberFormat = "0.0000"
Selection.NumberFormat = "0.000"
Selection.Copy
Range("D1").Select
ActiveSheet.Paste <---- ERROR STOPS HERE!!!
Application.CutCopyMode = False

Selection.AutoFilter Field:=1
Range("E1").Select

ActiveCell.FormulaR1C1 = "=AVERAGE(C[-1])"
Range("F1").Select
ActiveCell.FormulaR1C1 = "=COUNT(C[-2])"
Range("F2").Select

End With
Next I
Else
MsgBox "There were no files found"
End If
End With
End Sub

Regards,

Bharesh Mandalia

nyc_guy

Error 1004 - Out of Memory
 
The only time that I have experienced the out of memory error is whe
the record I am tring to copy and paste has a field that has a larg
amount of data. For me it is usually a description field that has
vey long email thread.

Take a look at the record the macro is erroring out on. You may fin
that on of the fields has a large amount of data. I'm not sure on ho
to correct this issue.

Good luck

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 07:16 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com