JungleDiff
JungleDiff

Reputation: 3505

using Application.WorksheetFunction.MRound and Cells.Formula

I am trying to write excel formulas using Cells.Formula and Application.WorksheetFunction.MRound

I want to leave the formulas in the cells but it only leaves the values, not the formulas.

How do I leave the formulas in the cells?

Upvotes: 0

Views: 127

Answers (2)

teylyn
teylyn

Reputation: 35935

The Application.WorksheetFunctions are not meant to be placed into cells, but will perform the calculation of a worksheet function in VBA.

If you want to place a formula into a cell you need to use one of the Formula properties, for example

Range("A1").Formula ' or
Range("A1").FormulaR1C1

See this question for an example of both.

Upvotes: 1

Absinthe
Absinthe

Reputation: 3391

Instead of cell.value = Application.WorksheetFunction.MRound use cell.formula = "=MRound". I.E. put the formula as you'd write it in a cell into the cell as a string.

Upvotes: 0

Related Questions