SalmanGenProg
New Member
- Joined
- May 24, 2010
- Messages
- 19
Dear All,
I am running a simple macro that copies and pastes data from one spreadsheet into another and then makes a calculation and loops around in order to repeat the procedure (usually around 40 or so times). The code is very simple and i'm pasting it below. Of late my spreadsheet has started to crash very often. I usually manage to get one full run out of it, but then it never runs the macro fully; always crashing a couple of turns into the PLoop variable (see below). And I then get an error message saying "The picture is too large and will be truncated". At that point excel also hangs and I have to restart the computer. My spreadsheet is relatively big (around 50MB and has around 9000 rows filled with links to other spreadsheets - each of which is around 50MB in size as well).
Any ideas as to how I could resolve this would be most appreciated.
Here's the code:
I am running a simple macro that copies and pastes data from one spreadsheet into another and then makes a calculation and loops around in order to repeat the procedure (usually around 40 or so times). The code is very simple and i'm pasting it below. Of late my spreadsheet has started to crash very often. I usually manage to get one full run out of it, but then it never runs the macro fully; always crashing a couple of turns into the PLoop variable (see below). And I then get an error message saying "The picture is too large and will be truncated". At that point excel also hangs and I have to restart the computer. My spreadsheet is relatively big (around 50MB and has around 9000 rows filled with links to other spreadsheets - each of which is around 50MB in size as well).
Any ideas as to how I could resolve this would be most appreciated.
Here's the code:
Code:
Sub LoadP()
On Error GoTo ErrorTrap
Windows("Psizing.xlsm").Activate
Range("MF") = 0
Range("PF") = 0
Windows("BCap.xlsm").Activate
'CLEANING UP OLD DATA IN ALL DUMP-SHEETS
Workbooks("BCData").Activate
Worksheets("ATRtracker").Select
Range("ATRtrackerDump").Select
ActiveCell.Range("A1:az10000").Select
Application.CutCopyMode = False
Selection.ClearContents
Worksheets("PosTracker").Select
Range("PosTrackerDump").Select
ActiveCell.Range("A1:az10000").Select
Application.CutCopyMode = False
Selection.ClearContents
Worksheets("UBreak").Select
Range("UBreakDump").Select
ActiveCell.Range("A1:az10000").Select
Application.CutCopyMode = False
Selection.ClearContents
Workbooks("BCap").Activate
Worksheets("TLog").Select
Range("TLogposting").Select
Range(Selection, Selection.End(xlToRight)).Select
ActiveCell.Range("A1:I5000").Select
Application.CutCopyMode = False
Selection.ClearContents
Worksheets("Control Panel").Select
Range("FirstMark").Select
Range("g8:dx8").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.ClearContents
ActiveCell.Offset(-1, 0).Range("A1").Select
Calculate
LoopLength = Range("TotalM")
'COPYING DATA INTO THE DUMP-SHEETS
Sheets("Bio 2.0").Select
Application.Goto Reference:="DateSet"
Selection.Copy
Sheets("Control Panel").Select
Range("datadumpstart").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
For PLoop = 1 To LoopLength
Worksheets("Control Panel").Select
Range("PItemStart").Select
ActiveCell.Offset(PLoop - 1, 0).Range("A1").Select
Selection.Copy
Sheets("Bio 2.0").Select
Application.Goto Reference:="sMkt"
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Calculate
Application.Goto Reference:="DlyPL"
Application.CutCopyMode = False
Selection.Copy
Sheets("Control Panel").Select
Range("DataDumpStart").Select
ActiveCell.Offset(1, PLoop + 1).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Sheets("Bio 2.0").Select
Application.Goto Reference:="InitialP"
Application.CutCopyMode = False
Selection.Copy
Sheets("Control Panel").Select
Range("InitialPRef").Select
ActiveCell.Offset(0, PLoop).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Sheets("Bio 2.0").Select
Application.Goto Reference:="OpenTD"
Application.CutCopyMode = False
Selection.Copy
Workbooks("BCData").Activate
Sheets("PosTracker").Select
Range("PosTrackerDump").Select
ActiveCell.Offset(0, PLoop - 1).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Workbooks("BCap").Activate
Sheets("Bio 2.0").Select
Range("DTstop").Select
Application.CutCopyMode = False
Selection.Copy
Workbooks("BCData").Activate
Sheets("ATRtracker").Select
Range("ATRtrackerDump").Select
ActiveCell.Offset(0, PLoop - 1).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Workbooks("BCap").Activate
Sheets("Bio 2.0").Select
Range("UBreak").Select
Application.CutCopyMode = False
Selection.Copy
Workbooks("BCData").Activate
Sheets("UBreak").Select
Range("UBreakDump").Select
ActiveCell.Offset(0, PLoop - 1).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Workbooks("BCap").Activate
Sheets("Bio 2.0").Select
Application.Goto Reference:="TList"
Application.CutCopyMode = False
Selection.Copy
Application.Goto Reference:="TLogPosting"
Let ScrollLength = Range("TotalTrs") ' + 1
TLogLoop:
If ActiveCell.Offset(0, 0).Range("a1") = "" Then
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Else
ActiveCell.Offset(ScrollLength, 0).Range("a1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End If
ActiveSheet.Calculate
Next
'CLEANING UP THE BOTTOM PART OF THE TLOG DUMP
Application.Goto Reference:="TLogPosting"
Calculate
Let ScrollLength = Range("TotalTrs") ' + 1
ActiveCell.Offset(ScrollLength, 0).Range("A1:I1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Range("A1").Select
Worksheets("control panel").Select
Range("A1").Select
Calculate
Exit Sub
ErrorTrap:
response = MsgBox("Something went wrong")
End Sub