macro command for function key F9

Copper Contributor

Hello

I recorded a macro in Excel, one of the commands recorded in the macro was to calculate a formula (function key F9).

When I opened the macro for editing, this was the line that appeared in the editor:

ActiveCell.FormulaR1C1 = "2000"

("2000" is the calculated value of this particular formula - so written as an absolute value, instead of a command to calculate formula (F9).

 

is there any way to write/record this command in macro (Excel)?

 

TNX

 

3 Replies

@dentalior32 

If you want to recalculate the active cell:

 

ActiveCell.Calculate

 

If you want to recalculate all cells in the current selection:

 

Selection.Calculate

 

If you want to recalculate the active worksheet:

 

ActiveSheet.Calculate

 

If you want to recalculate the workbook:

 

ActiveWorkbook.Calculate

 

If you want to recalculate all open workbooks:

 

Application.Calculate

@Hans Vogelaar 

Hi,

 

Thank you!!!

sadly Im still having trouble with that (sorry, just beginner...)

 

I'm not sure what's the Command syntax.

 

this in my Macro:


ActiveCell.FormulaR1C1 = "The price is set"
ActiveCell.Offset(0, 8).Range("A1").Select
ActiveCell.FormulaR1C1 = "2000"
ActiveCell.Offset(0, -8).Range("A1").Select

End Sub

 

The yellow line is my problem...

can you please show me the full syntax in order to calculate the selected cell?

 

TNX

 

@dentalior32 

If both the active cell and the cell 8 columns to the right contain formulas:

 

    ActiveCell.Calculate
    ActiveCell.Offset(0, 8).Calculate