Macro Gradually Uses Up All Of Memory And Slows Down?
Mar 24, 2013
I have written this macro which I run about 1000 times in a loop. It runs solver and copies the results to a row in my spreadsheet so i end up with a sheet of solver results.
The problem is that every time it runs it eats up memory and slows down. I timed it and the first 100 runs take about 2 minutes and the last 100 takes about 15 minutes, the ram use increases by about 4gb in that time too.
As this is the first VBA code I have written and I have been learning as I go along, I assume its something I have done wrong in the code.
Sub run()
'
' run Macro
' run solver
[Code].....
View 2 Replies
ADVERTISEMENT
Jan 29, 2007
I've been using the following bit of code to run a macro at the specified time:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
Application .OnTime TimeValue("12:00:00"), "GetData"
End Sub
The GetData sub executes a shell script and then pulls data from the result. The problem is that the macro runs 140+ times, and so I get 140 windows popping up and the system practically stops. I can't figure out why this is happening, as there are no loops or any sort of repetition in the code. Any help is greatly appreciated as this problem occurs with more than just the one spreadsheet.
View 9 Replies
View Related
Dec 15, 2007
it crashes after one or two macro-plays and you are forced to restart Excel. With a 7MB file, this can cause some frustration due to the time it takes to load the file.
The tool is used to make graphs, and my code works with an umbrella macro that " loops" through a main macro depending on the number of graphs the user wants. From the error messages, I am guessing that the causes are either my userforms or my variables (I try to release them, but not sure if I am doing it right), but either way, I just want it to stop crashing.
Here is the code (I didn't include all of the side macros due to sheer length. I can if need be...):
Public comp As String
Public mega As String
Public custom As String
Public total As String
Public floored As String
Public PPName As String
Public SScreen As Boolean
Public multiG As Boolean
Public multipp As Boolean
Public one As Boolean
Public two As Boolean
Public three As Boolean
Public four As Boolean
Public five As Boolean
Public six As Boolean
Public seven As Boolean
Public eight As Boolean
View 9 Replies
View Related
Aug 22, 2013
I have a workbook I update from numerous sources every day. A few months ago I noticed some of my formatting started to disappear - a couple of borders were missing. a day or two later a couple of cells which had color were no longer colored. number formatting reverted to general so my percentages just showed up as decimals and my dollar values no longer had a $ or commas. Eventually - over the course of several weeks - all formatting in the document was completely gone. A couple of times throughout this process I tried replacing all the formatting, but as soon as I'd save the file, close it and open it back up whatever formatting related changes I had made would again disappear.
Eventually I went back a couple months and pulled an old file which still had its formatting and updated that instead. This worked fine... for about 2 months. three days ago I started noticing the same issues - a few borders disappeared in the file. two days ago a few more borders were gone and a couple of cells lost their color. yesterday and today it has gradually gotten worse again.
View 4 Replies
View Related
Aug 18, 2007
I have a macro that is performing a lot of string comparisons and sorting out a lot of unformatted data using a loops and instr calls and passing results into arrays to store in a database. The macro works flawlessly, however as the macro runs, over time is gets slower and slower until its barely moving 10% as fast as it was to start.
I run the macro in a separate windows session so I can continue working w/o the macro affecting other excel related tasks I work on. I can tell the computer begins to slow down as the macro runs. Is their any way to clear the system memory while the macro is running, maybe every 5 minutes or something?
View 4 Replies
View Related
Jun 17, 2014
I need an OFFSET function to start off by moving down 1 row from the starting point and then on the next run through the loop, to move down 2 rows, then 3 rows, etc.
Code:
Workbooks(Thisname).Worksheets("Run Set Up").Range("Duration").Offset(1, 0).Value = Workbooks(Filename2).Worksheets("Front Page").Range("T20").Value
This is what I'm working with. At the moment, I have the value for the number of rows to move set to 1 because I can't figure out how I'd accomplsih what I need.
View 1 Replies
View Related
Jul 5, 2009
I am trying to convert cells (all in column D) which are separated by "~" into columns. Unfortunately, running the text to columns command on several rows at a time can cause Excel to panic with an out of memory error (error #7 etc.).
The file is ~100mb and contains 500k-700k rows (I have 4GB of RAM so I know this is more a limit of Excel's 2GB RAM constraint).
Can you please help me write a macro to text to column convert each cell in column D?
I tried a macro which started with a for loop, and called the function for each cell individually, but even this led to an out of memory exception after 156,000 rows (although the same macro worked fine on a similar sheet with 700,000 rows).
Are there any other ways of clearing the Excel buffer/temporary space during the function calls to avoid causing Excel to crash?
View 9 Replies
View Related
May 2, 2008
Is there a faster method than this code? it slows way down when the range is expanded b/c it loops through every cell.
Private Sub Worksheet_SelectionChange(ByVal target As Range)
If target.Cells.Count > 1 Then Exit Sub
Set Rng = Range("A1:GA400")
clrind = 42
If Not Intersect(target, Rng) Is Nothing Then
For Each cell In Rng
If cell.Interior.ColorIndex = clrind Then cell.Interior.Pattern = xlNone
Next cell
End If
End Sub
View 9 Replies
View Related
Feb 18, 2010
I have a macro running in Word (and referencing Excel) that is meant to iterate 15,000 times. But, after 100 times, the process slows and stalls.
I have put in a few "DoEvents" and "ActiveDocument.UndoClear" in Word, and I set "Application.EnableEvents = False" in Excel. These settings got me up to 100 iterations (previously the program would stop after even fewer )
Does anyone have any ideas or suggestions? I'm not sure what information you'd need to be informed about the problem, and I don't want to tell you too much! Do please ask if I'm not being clear.
View 9 Replies
View Related
Mar 31, 2009
I have a SheetSelectionChange event that stores the Target.Row in a cell on the active worksheet.
View 15 Replies
View Related
Feb 26, 2005
I have an AutoFilter list of 14,000 rows by 14 columns, and the cells have some specific formating: fill color, font,
protection status, wrap, etc....
There are an additional 7 columns of formulas to the left of the filtered range.
The strange thing is----
-WITH the formating, trying to Unfilter the list takes 2 min, via a manually activated Data>Filter>ShowAll OR via a macro run of 'ActiveSheet.ShowAllData' .
(In an attempt to optimize speed, the VBA macro sets calculation to manual before the 'ActiveSheet.ShowAllData' and screen updating set to false.)
-WITHOUT the cell formating (eg. by doing Edit>Clear>Formats), the ShowAll takes about 3 sec.
Does anyone have experience or an explanation for this?
Why should the Formating affect Filtering so much?
Options for improving speed of autofilter?
I don't know if, or why it would be a factor, but note that I am using Dynamic Named Range and VBA to expand/contract the formulas
and formating to size of the list/table. Although this is not done during the filtering use.
Here is the dynamic formating code
Sub DynFmt_List()
Application. ScreenUpdating = False
With Application
.Calculation = xlManual
End With
I am wondering if some strange 'artifact' of manipulating the formating is becoming a factor?
View 4 Replies
View Related
Mar 16, 2013
I like the look of when only the used columns and rows are shown. I like to hide all unused columns and rows, and have the background and a minimalist spreadsheet.
HOWEVER, is it just me, or does Excel move a lot slower when thousands of rows and columns are hidden? Particularly, opening files seems to be slower. I'd love to delete them entirely from existence, so Excel only has a few rows and columns to work with, but that doesn't seem to be an option.
View 2 Replies
View Related
Dec 15, 2006
I have name 28 columns. The range in EACH columns is 6:14000, i.e. the first name is date and the range is from Row B6 to Row B14000.
I am using SumProduct instead of VlookUp to look up values. An example of one of my sumproduct formulas:
SUMPRODUCT(--(Date=$B$6),--(Book=$D$6),PnL___Book)
where the first columns has dates, the next column is bookname and the last column is the profit and loss for each book, i.e. the values that need to be addad.
Now, suddenly I do not get any numbers but just #VALUE! but if I change the range to a lot less, e.g. between Row B6 and B50, it works.
My questions is if this has to do with memory in Excel. Are there limits to how many formulas and how many names you can have before Excel crashes. I am aware that the 28 columns names are very large.
Are there any way of how to get around this, VBA-codes or other formulas that uses less power, not naming columns or what?
View 9 Replies
View Related
Oct 29, 2009
I have an excel sheet that has an onclose macro, and on certain computers i get an error message stating out of memory. can anyone explain why this is and how i could avoid it, by possibly clearing the memory first or something?
View 9 Replies
View Related
Aug 22, 2008
i have a spreadsheet on Excel 2000, which is 256 column's wide and 4000 long the only formulas are countif which start at row 1000-4000 and are copied to column 256. Just for the one sheet it is 14mb is this normal
View 11 Replies
View Related
Mar 31, 2009
I am currently using Excel 2003 to pull from 2 external spreadsheets to compile data. The first sheet (seniority list.xls) being referenced contains all of our employees (approximately 350 rows, but that can vary from 340 to 450) as well as some information (employee ID, full time or part time, etc.). The second sheet being referenced (pay.xls) contains a breakdown of all employees and their pay for a particular bi-weekly period.
What I'm looking to do is:
(1) Find out all of my current employees. I do this by referencing seniority list.xls.
(2) For each employee, find out how many hours they worked each week. I need to do this by referencing pay.xls. Unfortunately, that file works quite differently than seniority list.xls. Unlike the latter, which contains one employee number per row, pay.xls could contain as many or as few rows per employee as their schedule dictates. Each row contains things such as overtime, regular time, double time, alternate regular time, alternate OT, vacation, sick pay, etc. In total, pay.xls could contain as many as approximately 8000 rows. To determine how many hours they work, I'm using this CSE (array) formula:
(Note that the employee ID is in column A of the current sheet.)
View 9 Replies
View Related
Dec 23, 2013
I have a large amount of data on NBA teams and players that is extracted from external web pages. In order to have the data shown on separate sheets to do comparisons I have to use many array formulas and from what I have read that takes up a large amount of memory. I'm now at the point where I'm receiving a message that says "Excel cannot complete this task with available resources" when I open the workbook.
Is there any plausible way that I can resolve this situation? I have thought about converting the lookup formulas from arrays (index/match) to vlookups and hlookups.
I'm not as advanced with using Excel as most of you, and I realize I may be at a point to where I will need to use different software to analyze my data, but I would prefer to stick with Excel as it would be difficult to start from scratch and learn how to use a different program.
View 3 Replies
View Related
Nov 3, 2008
Using Excel 2007, Windows XP, 4gig ram,
I got this "Insufficient Memory .... close some application" message, once in a while.
I know that i got enough memory to run my Excel.
This is a random problem. Memory as been checked with mem86 and it work fine
View 9 Replies
View Related
Oct 4, 2006
Regarding the Memory Leak problem with ADO, does anyone know of a workaround?
The workaround mentioned on Microsoft's website (http://support.microsoft.com/default...;en-us;Q319998) pertains to using ADO to retrieve a recordset from an Excel worksheet, not from an Access Database.
1) Does anyone know if those workarounds would also address retrieving a recordset from an Access Database?
2) If so, is the "SELECT INTO" workaround effective?
Is this Memory Leak issue relatively minor or only affecting Excel 2000? I'm guessing it must be one of those 2 things since the concensus is ADO is superior to MSQuery..
View 2 Replies
View Related
Dec 6, 2006
I'm using a Dell P4, 1.6Ghz, 512Mhz of memory (Win2K & Excel 2003), and it's bogging on spreadsheets that aren't that big and complicated (compared to thing's I did years ago, in the days of 386's and Win98)...
It hits the 100% CPU usage and stays there for minutes (especially when saving) on files that are only around 2M in size, yet it's not using much of the memory...
Spreadsheets large or small seem to have little effect on how much memory is being used... is Win2K allocating a fixed % of total memory for Excel to use?... can this be changed, so Excel gets to use more of the available memory?
I've been cleaning up and redesigning my spreadsheets to make them more efficient, but there seems to be a disconnect between my hardware specs and Excel's performance with files that aren't that big ~:-/
Disabling my antivirus software (Nortons) prior to saving, seems to speed it up a little, but this is not something I should be having to do...
View 9 Replies
View Related
Apr 8, 2007
One of my apps I run is very large and memory intensive, and there are several subsequent procedures which tend to either bog down or errors out before the program finishes running.
Is there a way to clear the memory out?
And adding more physical memory is not an option, I have 4gigs already and Excel can only utilize 1gig anyway.
View 4 Replies
View Related
Jan 27, 2010
I have tried Tools/Options/Security Password to modify, but it can still be saved as a copy to the network which becomes very confusing to many. If I use Tools/Potect Sheet, I need to re-enter the password for all sheets twice. I am trying have it so that everyone is read only, select people can edit (with same password). Password protect all sheets and the workbook with the same password everytime when the workbook is closed
Basically 2 questions
1) Is there a way of remembering a password so that when the workbook is closed it and all sheets are automatically protected with the same password every time
2) Is it possible to have it not copied unless it is opened by an editor
View 2 Replies
View Related
Jan 17, 2014
I have been having an internal debate of how my worksheets shoud be configured.
My workbook could potentially contain 300+ worksheets, 10 control buttons and around 20 macros.
Each worksheet contains data in a range ~ A1:AC40 with many blank cells.
Do you think a workbook with this many worksheets would be unmanageable given the Comp Spec of the user PC below?
Most of the cells are simply short text data.
System info
Processor: 2.3Ghz Dual Processor
RAM: 2GB
32bit
View 7 Replies
View Related
Feb 3, 2010
I have created an excel tool w/ A LOT of macros in it, and the tool "speaks" to the SQL server (downloads data from it and uploads it back). My big problem now is that every time I run any of the VBA code the amount of RAM that is getting allocated to Excel (2007) is increasing - I am checking it in the Task Manager. So if I work for a long time without closing down Excel - my entire RAM is getting consumed and the system slows down, and sometimes crushes.
I was wondering if there is a way in VBA to clean up memory that is used by Excel.
Do you have any hints? I am using extensively 3 things - screenupdating off; displaymessages off, and calculations off. But this speeds up Excel but doesn't reduce the memory usage.
View 7 Replies
View Related
Jun 10, 2014
I have a macro which filters data on one sheet and copies that data onto 34 new sheets . This works perfectly until the 25th pass when Excel advises that there is insufficient memory to continue. I assumed that this was connected to the clipboard and its ability to remember 24 chunks of data so I turned it off but still Excel gave up at the 25th pass. Is there a way that I can clear the clipboard during the macro's execution or is there something else going on?
View 7 Replies
View Related
Jun 18, 2014
I have come across one of those annoying 'out-of-memory' errors. See my code below:
Code:
'Dimensions (first rows and cols)
Const frow3 As Integer = 17
Const frow4 As Integer = 19
Const fcol3 As Integer = 10
Const fcol4 As Integer = 11
Sub Extract()
Dim ws As Worksheet, target As Worksheet, meta As Worksheet
[Code] .......
The code executes fine until it gets to End Sub. Some object eats up memory but I don't understand which one.
View 6 Replies
View Related
Jun 19, 2007
How come I keep having the same value for "lastrow". eg: 35
lastrow = ActiveSheet.UsedRange.Rows.Count
It doesn't matter how many rows of data I've changed, it still show lastrow = 35.
I tried to add an extra line above but still doesn't work:
lastrow = 0
lastrow = ActiveSheet.UsedRange.Rows.Count
View 9 Replies
View Related
Jul 11, 2007
two parts:
1.
The following is the VBA version of what i've been using:
Range("A1:J1000").Sort Key1:=Range("D2"), Order1:=xlAscending, Key2:= _
Range("E2"), Order2:=xlAscending, Key3:=Range("F2"), Order3:=xlDescending _
, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, _
DataOption3:=xlSortNormal
now arrays are bigger than 1000 rows>> even bigger than 65536.
Such an array is stored in "arrBIG" and dimed as (1 to 10, 1 to 100000). The goal is to sort it by the 4'th, then 5th then 6th values in the first dimension - the one that is 1 to 10 - i call this the column.
arrBIG.Sort Key1:=4, Order1:=xlAscending, Key2:= _
5, Order2:=xlAscending, Key3:=6, Order3:=xlDescending _.................
View 9 Replies
View Related
Sep 9, 2008
I'm trying to import data into my sheet with formulae like this in row1(Columns A:I): ='F:Dir[File.xls]Sheet'!A2.
The files I'm importing the data from all have 50.000 rows and 9 columns, so I copy the formulae downward 50.000 times. This generates an error ('Not enough memory'), not surprisingly. I've also tried to do it in steps by way of VBA; first two thousand, copy and paste values, next two thousand etc. But that doesn't work either.
Does anyone know of a solution to this memory problem or a way to work around it (without opening the files with the data in them).
View 9 Replies
View Related
Dec 16, 2008
I have 2 userforms (userform1 and userform2)
userform1 has a combobox1 (list of customers) with an commandbutton1
userform2 has many textboxes
when I click on the userform1.commandbutton1 - userform2 shows with textbox1.text being what was in userform1.combobox1
when i am done with userform2 and click close to go back to userform1, chose a different customer and click the commandbutton1, userform2 opens with the previous value.
how can i clear the previous?
currently when i close userform2 with commandbutton1 i use the following code
Private Sub CommandButton1_Click()
unload userform2
set userform2 = nothing
End Sub
View 9 Replies
View Related