Excel VBA - How To Insert Plain Value without Formula?

reforrer picture reforrer · Apr 28, 2011 · Viewed 25.2k times · Source

I have skimmed many Excel VBA topics, however, I have not found any information about inserting plain values - the result of SUM() in this case - not formula. There is a method, PasteSpecial xlPasteValues, but it seems that it is not what I am looking for.

The following code example inserts the formula, not only the value:

Sub test()
    Range("A4").Value = "=SUM(A1:A3)"
End Sub

How do I insert plain values without the formula in Excel VBA?

Answer

shahkalpesh picture shahkalpesh · Apr 28, 2011

Here is what I think, you are looking for

range("a4").Value = Evaluate("SUM(A1:A3)")