macro to Update Formulas on all Sheets (F9)

howard

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

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

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,423
Messages
5,444,367
Members
405,278
Latest member
karen1

This Week's Hot Topics

Top