Name

range.FormulaR1C1

Synopsis

Sets or returns a formula for the specified cell or range in R1C1-style notation. It is easier to work with formulas in code using this notation. The following code sets a formula for cell E1:

ActiveSheet.Range("E1").FormulaR1C1 = "=Sum(R2C:R[-1]C)"

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.