Results 1 to 2 of 2

Thread: Calculate [RESOLVED]

  1. #1

    Thread Starter
    Addicted Member Fonty's Avatar
    Join Date
    May 2006
    Location
    New York
    Posts
    173

    Resolved Calculate [RESOLVED]

    I would like to know if it is possible to use Calculate in a workbook, only for a specific range? Instead of calculating the whole workbook.
    Last edited by Fonty; Jan 30th, 2007 at 05:39 PM.

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Calculate

    use Calculate in a workbook, only for a specific range? Instead of calculating the whole workbook.
    Unfortunately, there is no direct method to just calculate a specific range instead of calculating the whole workbook.

    You can, however, set the calculation mode to manual by following these steps:

    Choose Options from the Tools menu. Excel displays the Options dialog box.
    Make sure the Calculation tab is displayed.
    Select the Manual option.
    Click OK.

    Now the only time your workbook (actually, all your open workbooks) will be recalculated is when you press F9. If you want to recalculate only the current worksheet, then press Shift+F9.

    If you want you can now write a macro function that allow you calculate a specified range of cells on a worksheet. With this knowledge you could create a macro that would loop through all the worksheets in a workbook and recalculate each of them.

    The following macro sets the calculation mode to manual

    VB Code:
    1. Sub CalcBook()
    2.     Dim wks As Worksheet
    3.     Application.Calculation = xlManual
    4.     Set wks = Nothing
    5. End Sub

    If you believe that you may want to calculate different parts of your workbook at different times, you can expand the macro so that it will perform any type of calculation you may want:

    VB Code:
    1. Sub CalWhat()
    2.     Dim iAnsure As Integer
    3.  
    4.     Application.Calculation = xlManual
    5.     iAnsure = InputBox("1 = Calculate A Used Range" _
    6.       & vbCrLf & _
    7.       "2 = Calculate This Worksheet" _
    8.       & vbCrLf & _
    9.       "3 = Calculate This Workbook" _
    10.       & vbCrLf & _
    11.       "4 = Calculate All Workbooks in Memory" _
    12.       & vbCrLf & vbCrLf & _
    13.       "Input Your Selection Number From Above" _
    14.       & vbCrLf & "Then Click OK", _
    15.       "Calculate What?", "Input Number Please", _
    16.       5000, 5000)
    17.  
    18.     Select Case iAnsure
    19.         Case 1 'Range Only
    20.             Selection.Calculate
    21.         Case 2 'Worksheet Only
    22.             ActiveSheet.Calculate
    23.         Case 3 'Workbook Only
    24.             For Each wks In ActiveWorkbook.Worksheets
    25.                 wks.Calculate
    26.             Next
    27.         Case 4 'All Open Workbooks
    28.             Application.CalculateFull
    29.         End
    30.     End Select
    31. End Sub

    This macro presents an input box that prompts the user as to which type of recalculation is desired. When the user enters a number from 1 to 4, the desired type of recalculation is performed.

    Hope this helps...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

Posting Permissions

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



Click Here to Expand Forum to Full Width