macro to Update Formulas on all Sheets (F9)

howard

Well-known Member
Joined
Jun 26, 2006
Messages
5,527
I have written code to update my formulas instead of manually updating using F9
It is not updating all sheets, only the current sheet

Code:
Sub Refresh_Formula()
    Dim ws As Worksheet
    
    For Each ws In Worksheets
        ws.Calculate
    Next ws
End Sub

It would be appreciated if someone could correct my code
 

Some videos you may like

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Paul Ked

Active Member
Joined
Jun 4, 2015
Messages
442
Not sure if you have the sheet active to re-calculate, so try this:

Code:
Sub Refresh_Formula()
    Dim ws As Worksheet, ThisWs As Worksheet
    With Application
        .ScreenUpdating = False
        .EnableEvents = False
        Set ThisWs = ActiveSheet
        For Each ws In Worksheets
            ws.Activate
            ws.Calculate
        Next ws
        ThisWs.Activate
        .EnableEvents = True
    End With
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,095,783
Messages
5,446,477
Members
405,403
Latest member
horace james

This Week's Hot Topics

Top