简体   繁体   中英

is it possible to recalculate only a cell or a range in VBA

is it possible to recalculate only a cell or a range in VBA ? What I like to use for a sheet is the following, but how to do it on a cell only ? Or range ?

'    ActiveSheet.EnableCalculation = False
'    ActiveSheet.EnableCalculation = True

There is a calculate method you can call on ranges:

Range("A1").Calculate

Try it out by putting =Now() in A1 and running Calculate and watch it update the seconds :) You can for a recalc of all the cells in a sheet by using:

Sheets(1).Calculate

See also: Microsoft MSDN, Excel Recalculation , 16 July 2012.

Calculate: All open workbooks

Application.Calculate

Calculate: A specific worksheet

Worksheets(1).Calculate

or

Worksheets("sheetname").Calculate

Calculate: A specified row

Worksheets(1).Rows(2).Calculate

or

Worksheets("sheetname").Range("A1").EntireRow.Calculate

Recalculate in Excel

Select the cells you would like to recalculate and press:

Press F9

Try this:

Range("A1").Formula = Range("A1").Formula

or

Cells(1, 1).Formula = Cells(1, 1).Formula 

It works for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM