Consulting

Results 1 to 5 of 5

Thread: Question on ActiveWorkbook.Calculate

  1. #1

    Question on ActiveWorkbook.Calculate

    I have an quick question. The VBA code [VBA]ActiveWorkbook.Calculate [/VBA]does not calculate for all sheets in the active workbook?

    I believe NO. Can somebody verify it? If it is not then what will be the VBA code to calculate for all sheets for the active workbook.

    My workbook is presently set as 'Manual calculation' which I want to preserve because it is quite large size.

    Thanks and regards,

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    Application.CalculateFull
    ?

    It'a for all open workbooks.

    Help says Calculate is the same.

    Check out also:
    Application.CalculateFullRebuild
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    VBAX Mentor Teeroy's Avatar
    Joined
    Apr 2012
    Location
    Sydney, Australia
    Posts
    414
    Location
    You are right, .Calculate won't work on a workbook. The method only applies to the Application (all open workbooks), a worksheet, or a range (at least in excel 2003). If you need it limited to a specific workbook loop through the worksheets collection.
    _________________________________________________________________________
    "In theory there is no difference between theory and practice. In practice there is." - Chuck Reid

    Any day you learn something new is a day not wasted.

  4. #4
    Quote Originally Posted by Teeroy
    You are right, .Calculate won't work on a workbook. The method only applies to the Application (all open workbooks), a worksheet, or a range (at least in excel 2003). If you need it limited to a specific workbook loop through the worksheets collection.
        Dim i As Integer
    Dim wsheet As Worksheet
    For i = 0 To UBound(Worksheets)
        wsheet = Worksheets(i)
        wsheet.Calculate
    next

  5. #5
    VBAX Mentor Teeroy's Avatar
    Joined
    Apr 2012
    Location
    Sydney, Australia
    Posts
    414
    Location
    Quote Originally Posted by magelan
        Dim i As Integer
    Dim wsheet As Worksheet
    For i = 0 To UBound(Worksheets)
        wsheet = Worksheets(i)
        wsheet.Calculate
    next
    You are right Magelan, I shouldn't have assumed that the looping was was obvious. Another way to do this is:

    [vba]Dim wsheet As Worksheet
    For Each wsheet in Worksheets
    wsheet.calculate
    Next
    [/vba]
    _________________________________________________________________________
    "In theory there is no difference between theory and practice. In practice there is." - Chuck Reid

    Any day you learn something new is a day not wasted.

Posting Permissions

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