none
Automatic calculation in a cell RRS feed

  • Question

  • Hi,

    I was trying to customize the cell calculation behavior in Excel:

    1. In cell A1, A2, I entered 100, 200, respectively

    2. In cell A3, I enter =SUM(A1:A2), and I hit 'ENTER' key

    In normal case, it will starts calculation immediately, and show 300 in A3. However, I don't want the calculation to start after hitting the 'ENTER', I will have a ctrl-shift-A macro to trigger the calculation after I select cell A3. How can i achieve in excel VBA?

    Thanks,

    -Michael Y

    Wednesday, April 29, 2015 3:52 PM

All replies

  • Sub Macro1()
    Worksheets("Sheet1").Range("A3").Formula = "=SUM(A1:A2)"
    End Sub

    Sub Macro2()
    Worksheets("Sheet1").Range("A3").Value = Application.Sum(Worksheets("Sheet1").Range("A1:A2"))
    End Sub

    Sub Macro3()
    ActiveCell.FormulaR1C1 = "=SUM(R[-2]C:R[-1]C)"
    End Sub

    Sub Macro4()
    ActiveCell.Value = Application.Sum(ActiveCell.Offset(-2, 0).Resize(2, 1))
    End Sub


    Wednesday, April 29, 2015 6:12 PM