Hi everyone,
I have a fairly large excel file (~21MB) with a macro which performs about 400 goalseek runs. This macro has to run everytime a change is made in any of the 13 key input cells, and hence, should be pretty fast. The problem is that it currently takes about 8-10 minutes to run, a time which reduces by half if i copy-paste the sheet into another workbook and run the code there. It'd be great if you can help me with speeding up the excel code.
Here's the code:
I have a fairly large excel file (~21MB) with a macro which performs about 400 goalseek runs. This macro has to run everytime a change is made in any of the 13 key input cells, and hence, should be pretty fast. The problem is that it currently takes about 8-10 minutes to run, a time which reduces by half if i copy-paste the sheet into another workbook and run the code there. It'd be great if you can help me with speeding up the excel code.
Here's the code:
Sub MoU_Growth()
Dim i As Integer
Dim j As Integer
Sheets("MoU Projections (2)").SelectEnd Sub
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
For i = 3 To 20
For j = 63 To 84Next i
If Cells(j, i).Value <> 0 ThenNext j
Range(Cells(j + 27, i), Cells(j + 27, i)).CopyEnd If
Range("H59").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False 'to copy-paste current goal seek answers for a quicker goal seek run
Range(Cells(j, i), Cells(j, i)).GoalSeek Goal:=1, ChangingCell:=Range("H59")
Range("H59").Copy
Range(Cells(j + 27, i), Cells(j + 27, i)).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Application.StatusBar = "Working on cell " & Chr(64 + i) & j
Application.ScreenUpdating = True
Application.StatusBar = "Complete"
Application.Calculation = xlCalculationAutomatic