Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Range("a10") = "= a2 + a3 + a5" Range("a12").Formula = "=a2+a3+a5" both appear to give correct result. Then on what conditions the property "formula " is to be used. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Whe n you don't spesify what property to be used, the object's default will
be used. For cells that's Value. But what happens here is that Excel recognizes a value starting with = to be a formula, so she makes it a formula. So in this case it makes no difference for entry, but for retrieval and manipulation it's crucial. Note the last part of this little demo: Sub test() MsgBox "Will execute: Range(""a10"") = ""= a2 + a3 + a5""" Range("a10") = "= a2 + a3 + a5" MsgBox "Range(""a10""): " & Range("a10"), , _ "Not what you said a10 it should be ?" MsgBox "Range(""a10"").Formula: " & _ Range("a10").Formula & Chr(10) & _ "Range(""a10"").Value: " & _ Range("a10").Value, , _ "Note the difference:" MsgBox "Now let's do something stupid:" & Chr(10) & _ "Will execute: Range(""a10"") = Range(""a10"")" Range("a10") = Range("a10") MsgBox "Range(""a10"").Formula: " & _ Range("a10").Formula & Chr(10) & _ "Range(""a10"").Value: " & _ Range("a10").Value, , "Formula is destroyed:" End Sub -- HTH. Best wishes Harald Excel MVP Followup to newsgroup only please "R.Venkataraman" skrev i melding ... Range("a10") = "= a2 + a3 + a5" Range("a12").Formula = "=a2+a3+a5" both appear to give correct result. Then on what conditions the property "formula " is to be used. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
thanks.
"Harald Staff" wrote in message ... Whe n you don't spesify what property to be used, the object's default will be used. For cells that's Value. But what happens here is that Excel recognizes a value starting with = to be a formula, so she makes it a formula. So in this case it makes no difference for entry, but for retrieval and manipulation it's crucial. Note the last part of this little demo: Sub test() MsgBox "Will execute: Range(""a10"") = ""= a2 + a3 + a5""" Range("a10") = "= a2 + a3 + a5" MsgBox "Range(""a10""): " & Range("a10"), , _ "Not what you said a10 it should be ?" MsgBox "Range(""a10"").Formula: " & _ Range("a10").Formula & Chr(10) & _ "Range(""a10"").Value: " & _ Range("a10").Value, , _ "Note the difference:" MsgBox "Now let's do something stupid:" & Chr(10) & _ "Will execute: Range(""a10"") = Range(""a10"")" Range("a10") = Range("a10") MsgBox "Range(""a10"").Formula: " & _ Range("a10").Formula & Chr(10) & _ "Range(""a10"").Value: " & _ Range("a10").Value, , "Formula is destroyed:" End Sub -- HTH. Best wishes Harald Excel MVP Followup to newsgroup only please "R.Venkataraman" skrev i melding ... Range("a10") = "= a2 + a3 + a5" Range("a12").Formula = "=a2+a3+a5" both appear to give correct result. Then on what conditions the property "formula " is to be used. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Commenting custom formula fields/formula on formula editor | Excel Programming |