Reputation: 13
Usually when i enter a formula on excel it shows when i click on the cell, but when i use vba it only shows the value even when i click. I need to show the formula so i can use it as a target cell for a solver. The solver won't work if it's just a value.
Like for example i use
Set srange1 = Range("B2:B" & n + 1)
Sheets("Portfolio").Cells(2, 3 + n).Value = Application.Sum(srange1)
The cell contains only a value so i can't use a solver on it since it requires a formula.
Upvotes: 0
Views: 39
Reputation: 2066
use something like this
Set srange1 = Range("B2:B" & n + 1)
Sheets("Portfolio").Cells(2, 3 + n).Formula = "=SUM(" & srange1 .Address & ")"
Upvotes: 1