I have a macro that quits and displays the infamous "Excel cannot complete this task with available resources. Choose less data or close other applications." The file was originally an Excel 2003 (.xls) but has been converted to an .xlsm format after our recent Office 2007 upgrade.
Intent of selected portion of VB Code: Prepares a master workbook for new data to parse from our company's enterprise system (SAP). Parses this download and copies it to the master workbook. Removes blank rows and other garbage that results from the download (heading dividers, non-pertinent data).
The VB Code:
Sub Macro1()
'prepare for new data:
Sheets("From_Download").Select
Rows("3:65536").Select
'parse data:
Workbooks.OpenText Filename:="L:\Downloads\dlextract.xls", _
Origin:=xlWindows, StartRow:=1, DataType:=xlFixedWidth, FieldInfo:= _
Array(Array(0, 9), Array(1, 2), Array(20, 2), Array(46, 3), Array(56, 3), Array(67, 2), _
Array(78, 2), Array(81, 1), Array(90, 1), Array(106, 1), Array(122, 1), Array(131, 1), _
Array(140, 1), Array(149, 1), Array(158, 1), Array(167, 1), Array(176, 1), Array(185, 1), _
Array(196, 1), Array(203, 2), Array(214, 2), Array(219, 2), Array(221, 2), Array(224, 2), Array(229, 2), _
Array(238, 3), Array(249, 2), Array(253, 9)), TrailingMinusNumbers:=True
'copy data and close dl file:
Range("A1").Select
Range(ActiveCell, ActiveCell.Offset(0, 26).End(xlDown).Offset(0, -1).End(xlUp)).Select
Selection.Copy
Windows("COST_ESTIMATE_MASTER.xlsm").Activate
Sheets("From_Download").Select
Range("A3").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Windows("dlextract.xls").Activate
ActiveWorkbook.Close
Windows("COST_ESTIMATE_MASTER.xlsm").Activate
Sheets("From_Download").Select
'input test formula & Delete:
Range("AZ3").Select
ActiveCell.FormulaR1C1 = "=IF(ISNUMBER(RC[-43]),1,2)"
Selection.Copy
Range(ActiveCell, ActiveCell.End(xlDown).Offset(0, -51).End(xlUp).Offset(0, 51)).Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("A3:AZ65536").Select
Selection.Sort Key1:=Range("AZ3"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("AZ3").Select
Cells.Find(What:="2", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False).Activate
Range(ActiveCell, ActiveCell.End(xlDown).Offset(5, 0)).Select
Selection.EntireRow.Delete
--------------------------------------------------------
When the macro attempts to delete rows in the resorted range I receive the error message. There is much more to this macro but wanted to isolate only the portion that abends.
System:
XP Professional Version 2002 SP3
Intel Core 2 Duo CPU T1800 @ 2.6GHz
1.99GB RAM
Office 2007
VB version 6.5