VBA is turning off automatic workbook calculations

mst3k4L

Board Regular
Joined
Nov 3, 2011
Messages
55
Whenever I run this VBA code, the automatic workbook calculations are turned off, an d I have no idea why. Any ideas would be appreciated.

Code:
Sub solve_verror()
'
' solve_verror Macro
'
    Dim r As Long
    Dim i As Long
    Dim j As Long
    Dim LastRow
    Dim lastColumn
    Dim newColumns
    
    r = 24
    LastRow = Cells(Rows.Count, "A").End(xlUp).Row
    lastColumn = Cells(21, Columns.Count).End(xlToLeft).Column
    Range(Cells(r, 1), Cells(LastRow, lastColumn)).ClearContents
    
    'Inserts Required columns inside two V_leak summations
    tstep = Range("tstep")
    newColumns = Range("tinj") / tstep
    For j = 1 To (newColumns - 2)
        Columns("E:E").Insert Shift:=xlToLeft, CopyOrigin:=xlFormatFromLeftOrAbove
    Next
    Range(Cells(r - 1, 4), Cells(r - 1, 4)).AutoFill Destination:=Range(Cells(r - 1, 4), Cells(r - 1, 14)), Type:=xlFillDefault

    Do While Cells(r - 1, 1) < Range("tinj")
        Cells(r, 1) = Cells(r - 1, 1) + tstep
        Cells(19, r - 20) = Cells(r, 1)
        Cells(r, 2) = Cells(r, 1) * Range("q")
        Cells(r, 3) = Cells(r - 1, 3) + 1
        
        'Autofill has to include the original selected range
        Range(Cells(r - 1, 4), Cells(r - 1, 22)).AutoFill Destination:=Range(Cells(r - 1, 4), Cells(r, 22)), Type:=xlFillDefault
        Rows(20).Clear
        'Places variable on length row on top to match L_estimated column
        For i = 23 To LastRow
            Cells(20, i - 20).Formula = "=C" & i
        Next
        
        SolverOk SetCell:=Cells(r, 20), MaxMinVal:=3, ValueOf:="0", ByChange:=Cells(r, 3)
        SolverSolve UserFinish:=True
   
        SolverSolve (True)
        r = r + 1
    Loop
End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
maybe add this to the end?
Code:
Application.Calculation = xlCalculationAutomatic
 
Upvote 0

Forum statistics

Threads
1,214,647
Messages
6,120,722
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top