Consulting

Results 1 to 7 of 7

Thread: Automatic Calculation when sheet tab clicked

  1. #1
    VBAX Newbie
    Joined
    Aug 2012
    Posts
    4
    Location

    Automatic Calculation when sheet tab clicked

    Hi All. I have a excel spreadsheet with certain marcos built in. I need a method to automatically calculate the sheet.
    Such as;
    Activesheet.CalculateFull
    or an alternative to Ctrl +alt + F9

    Ideally I would live to activate it when the user navigates using the sheet tabs in excel, so when the user clicks page 5 tab for example that sheet calculates. I could create buttons to go to next page/previous pages that trigger the calculation but ideally want it to go through users clicking on the excel sheet tabs. Can this be done by inserting a new module into the VBA?

    Thank you for reading!

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Welcome to the forum!

    In ThisWorkbook object:
    [VBA]Private Sub Workbook_Open()
    ActiveSheet.Calculate
    End Sub

    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    Sh.Calculate
    End Sub
    [/VBA]

  3. #3
    VBAX Newbie
    Joined
    Aug 2012
    Posts
    4
    Location
    Thanks Kenneth. I'm afriad the code doesn't work for my case! Is there anything stronger than the .calculate method. Crtl alt F9 works. is there a calculateRebuild or something similar?

  4. #4
    VBAX Newbie
    Joined
    Aug 2012
    Posts
    4
    Location
    if a create a button

    Application.CalculateFull

    works; however I tried to fit this into your code, and it still won't automatically update when i open the page. Instead it works if i click on a cell and push enter

    Private Sub Workbook_Open()
    Application.CalculateFull
    End Sub

    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

    Application.CalculateFull
    End Sub

    Sorry I am a complete newbie at this!!!

  5. #5
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    In the VBE, did you doubleclick ThisWorkbook and paste the workbook code that you last posted in that object?

  6. #6
    VBAX Newbie
    Joined
    Aug 2012
    Posts
    4
    Location
    Yes, double clicked the thisworkbook object and inserted the code!

  7. #7
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Post a short example workbook and tell us how it needs to work if you like.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •