macro command for function key F9

%3CLINGO-SUB%20id%3D%22lingo-sub-2298011%22%20slang%3D%22en-US%22%3Emacro%20command%20for%20function%20key%20F9%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2298011%22%20slang%3D%22en-US%22%3E%3CP%3EHello%3C%2FP%3E%3CP%3EI%20recorded%20a%20macro%20in%20Excel%2C%20one%20of%20the%20commands%20recorded%20in%20the%20macro%20was%20to%20calculate%20a%20formula%20(function%20key%20F9).%3C%2FP%3E%3CP%3EWhen%20I%20opened%20the%20macro%20for%20editing%2C%26nbsp%3Bthis%20was%20the%20line%20that%20appeared%20in%20the%20editor%3A%3C%2FP%3E%3CP%3EActiveCell.FormulaR1C1%20%3D%20%222000%22%3C%2FP%3E%3CP%3E(%222000%22%20is%20the%20calculated%20value%20of%20this%20particular%20formula%20-%20so%20written%20as%20an%20absolute%20value%2C%26nbsp%3Binstead%20of%20a%20command%20to%20calculate%20formula%20(F9).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eis%20there%20any%20way%20to%20write%2Frecord%20this%20command%20in%20macro%20(Excel)%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETNX%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2298011%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2298027%22%20slang%3D%22en-US%22%3ERe%3A%20macro%20command%20for%20function%20key%20F9%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2298027%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1038417%22%20target%3D%22_blank%22%3E%40dentalior32%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20want%20to%20recalculate%20the%20active%20cell%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EActiveCell.Calculate%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20want%20to%20recalculate%20all%20cells%20in%20the%20current%20selection%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESelection.Calculate%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20want%20to%20recalculate%20the%20active%20worksheet%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EActiveSheet.Calculate%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20want%20to%20recalculate%20the%20workbook%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EActiveWorkbook.Calculate%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20want%20to%20recalculate%20all%20open%20workbooks%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EApplication.Calculate%3C%2FP%3E%3C%2FLINGO-BODY%3E
New 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