Entering Formula Programmatically in VBA

M

MatthewS

I'm trying to put formulas into cells like this:


formulas(1) = "=Multiply(10,10)"
formulas(2) = "=Multiply(20,10)"

For i = 1 To 2
tempArray(i) = formulas(i)
Next i

outRange.Value = tempArray

This correctly puts the strings into the cells in the range, but they
are not evaluated. I have to select each cell in the sheet and go into
the formula bar and hit enter so that they are evaluated. Then they
work fine.

How can I get these cells to evaluate from VBA? I've tried
outRange.Calculate and Application.CalculateFull, but they don't do
the trick.

Do I have the wrong approach to entering a formula in a cell
programmatically? How can this be done?

Thanks
 
C

Clif McIrvin

try > outRange.Formula = tempArray



MatthewS said:
I'm trying to put formulas into cells like this:


formulas(1) = "=Multiply(10,10)"
formulas(2) = "=Multiply(20,10)"

For i = 1 To 2
tempArray(i) = formulas(i)
Next i

outRange.Value = tempArray

This correctly puts the strings into the cells in the range, but they
are not evaluated. I have to select each cell in the sheet and go into
the formula bar and hit enter so that they are evaluated. Then they
work fine.

How can I get these cells to evaluate from VBA? I've tried
outRange.Calculate and Application.CalculateFull, but they don't do
the trick.

Do I have the wrong approach to entering a formula in a cell
programmatically? How can this be done?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top