expression.Formula
expression Required. An expression that returns a Range object.
Example
This example sets the formula, column width, and number format for cell B5 on Sheet1 in Spreadsheet1.
Sub SetFormula()
Dim rngRandomNum
' Set a variable to cell B5 on Sheet1.
Set rngRandomNum = Spreadsheet1.Worksheets("Sheet1").Range("B5")
' Insert a formula into cell B5.
rngRandomNum.Formula = "=5*RAND()"
' Set the number format for cell B5.
rngRandomNum.NumberFormat = "#.###"
' Autofit column B.
rngRandomNum.Columns.AutoFit
End Sub