Thank you Basole for your message! I have been already using your recommendation on my code, but it still takes a lot of memory.
Regards, Isabel On Saturday, September 12, 2015 at 9:20:05 AM UTC-5, Basole wrote: > > Hi isabel, try using "Application.ScreenUpdating = False" To Turn Off at > the start of code. and "Application.Calculation = xlCalculationManual" To > turn off the automatic calculation > at the beginning of the code > see example: > > Dim u As Integer, v As Integer > u = Range("Months").Value - 1 > Application.ScreenUpdating = False 'To Turn Off at the start of code. > Application.Calculation = xlCalculationManual 'To turn off the automatic > calculationIf u > 1 Then > For v = 1 To u - 1 > Application.Goto Range("ColumnLong"), True > Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove > Application.Goto Range("ColumnFormulas"), True > Selection.Copy > Selection.Offset(0, -2).Select > Selection.PasteSpecial Paste:=xlFormulas, Operation:=xlNone, SkipBlanks:= > _ > False, Transpose:=False > Application.CutCopyMode = False > Next v > > ElseEnd If > Application.ScreenUpdating = True 'To Turn on at the end of the code. > Application.Calculation = xlCalculationAutomatic 'To turn On the automatic > calculation > > > Regards. > > > > 2015-09-11 13:31 GMT-03:00 Isabel Cristina Ortiz <ior...@gmail.com > <javascript:>>: > >> Hello, >> I have been working on a workbook. It is a cash flow and macro helps me >> to change the numbers of years (columns) because each project needs >> different time periods. >> What I do is that I have two columns named as "ColumnLong" and >> "ColumnFormulas". The first one is empty and only serves as a reference >> point to add more cells to the left to it, according to the number of >> months of the cash flow. >> Then, I always check the number of months on a specific cell named >> "Months" and I have a loop, it insert a column left to "ColumnLong", then >> goes to "ColumnFormulas" and it paste it into the new column which is two >> columns left to "ColumnFormulas". >> >> What I need is a simpler code because I have several loops similar to >> this one and I am having memory problems. >> I have been working on some recommendations I found on >> http://www.excelitems.com/2010/12/optimize-vba-code-for-faster-macros.html >> but wasn't able to apply to this code. >> >> I hope you can help me. >> Best regards, >> Isabel >> >> >> This is the code I am using: >> >> Dim u As Integer, v As Integer >> u = Range("Months").Value - 1 >> >> If u > 1 Then >> For v = 1 To u - 1 >> Application.Goto Range("ColumnLong"), True >> Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove >> Application.Goto Range("ColumnFormulas"), True >> Selection.Copy >> Selection.Offset(0, - 2).Select >> Selection.PasteSpecial Paste:=xlFormulas, Operation:=xlNone, >> SkipBlanks:= _ >> False, Transpose:=False >> Application.CutCopyMode = False >> Next v >> >> Else >> End If >> >> >> >> >> >> -- >> Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s >> =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ >> https://www.facebook.com/discussexcel >> >> FORUM RULES >> >> 1) Use concise, accurate thread titles. Poor thread titles, like Please >> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice >> will not get quick attention or may not be answered. >> 2) Don't post a question in the thread of another member. >> 3) Don't post questions regarding breaking or bypassing any security >> measure. >> 4) Acknowledge the responses you receive, good or bad. >> 5) Jobs posting is not allowed. >> 6) Sharing copyrighted material and their links is not allowed. >> >> NOTE : Don't ever post confidential data in a workbook. Forum owners and >> members are not responsible for any loss. >> --- >> You received this message because you are subscribed to the Google Groups >> "MS EXCEL AND VBA MACROS" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to excel-macros...@googlegroups.com <javascript:>. >> To post to this group, send email to excel-...@googlegroups.com >> <javascript:>. >> Visit this group at http://groups.google.com/group/excel-macros. >> For more options, visit https://groups.google.com/d/optout. >> > > -- Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ https://www.facebook.com/discussexcel FORUM RULES 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Jobs posting is not allowed. 6) Sharing copyrighted material and their links is not allowed. NOTE : Don't ever post confidential data in a workbook. Forum owners and members are not responsible for any loss. --- You received this message because you are subscribed to the Google Groups "MS EXCEL AND VBA MACROS" group. To unsubscribe from this group and stop receiving emails from it, send an email to excel-macros+unsubscr...@googlegroups.com. To post to this group, send email to excel-macros@googlegroups.com. Visit this group at http://groups.google.com/group/excel-macros. For more options, visit https://groups.google.com/d/optout.