+ Reply to Thread
Results 1 to 3 of 3

calculate cell formulas during VBA sub

  1. #1
    DonJ-Austin
    Guest

    calculate cell formulas during VBA sub

    Is there a way to get cell formulas (preferably certain formulas in a cell or
    range) to run at a designated point in a VBA subroutine ?

    I have a straightforward table lookup process (formula, array, etc) that
    would take a LOT of VBA code to accomplish equivalent function.

    Cheers. dj

  2. #2
    LenB
    Guest

    Re: calculate cell formulas during VBA sub

    DonJ-Austin wrote:
    > Is there a way to get cell formulas (preferably certain formulas in a cell or
    > range) to run at a designated point in a VBA subroutine ?
    >
    > I have a straightforward table lookup process (formula, array, etc) that
    > would take a LOT of VBA code to accomplish equivalent function.
    >
    > Cheers. dj


    If you have calculation set to manual (tools - options - calculation
    tab), your formulas can be made to run using Application.Calculate or
    Worksheets("Sheet1").Calculate, for example. VBA can set the
    calculation mode using Application.Calculation =
    [xlCalculationAutomatic, xlCalculationManual or
    xlCalculationSemiautomatic]. If your table is a data table, (from the
    Data menu), semiautomatic will require manual calculation for formulas
    in data tables. That might be a way to manually run formulas only in
    certain cells. I have never used Data Tables, so I don't know any more
    details.

    HTH
    Len

  3. #3
    Registered User
    Join Date
    02-11-2005
    Posts
    85
    Try inserting the line "Calculate" without the quotes when you want the formulas to be figured.

    for example:

    Sub runcalc()
    ActiveCell.FormulaR1C1 = "5"
    Calculate
    Range("A7").Select
    ActiveCell.FormulaR1C1 = "4"
    Range("A8").Select
    End Sub

    this puts a value of 5 in the active cell calculates the worksheet then continues with the code.

    Hope it helps.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1