macro to Update Formulas on all Sheets (F9)

howard

Well-known Member
Joined
Jun 26, 2006
Messages
5,449
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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

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,090,361
Messages
5,414,000
Members
403,511
Latest member
Emmanuel John

This Week's Hot Topics

Top