ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   use of activecell.formula (https://www.excelbanter.com/excel-programming/361274-use-activecell-formula.html)

R..VENKATARAMAN

use of activecell.formula
 
among these two code statements which is better

activecell.Formula="=sum(a1:a5)"
activecell=worksheetfunction.Sum(range("a1:a5"))




Chip Pearson

use of activecell.formula
 
It depends on what your needs are. The first,

activecell.Formula="=sum(a1:a5)"

will insert a formula, so its result will change as the values in
A1:A5 changs.

The second,

activecell=worksheetfunction.Sum(range("a1:a5"))

will return a number which will not changes as the values in
A1:A5 change, unless of course you re-run the code.

Without further detail, I would likely use the first approach.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"R..VENKATARAMAN" wrote in message
...
among these two code statements which is better

activecell.Formula="=sum(a1:a5)"
activecell=worksheetfunction.Sum(range("a1:a5"))






R..VENKATARAMAN

use of activecell.formula
 
thank you Mr. Pearson.


"Chip Pearson" wrote in message
...
It depends on what your needs are. The first,

activecell.Formula="=sum(a1:a5)"

will insert a formula, so its result will change as the values in A1:A5
changs.

The second,

activecell=worksheetfunction.Sum(range("a1:a5"))

will return a number which will not changes as the values in A1:A5 change,
unless of course you re-run the code.

Without further detail, I would likely use the first approach.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"R..VENKATARAMAN" wrote in message
...
among these two code statements which is better

activecell.Formula="=sum(a1:a5)"
activecell=worksheetfunction.Sum(range("a1:a5"))









All times are GMT +1. The time now is 05:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com