adding formula to cell

J

jodleren

Hi


I seem to have problems to add a formula to a cell.

I generat a string like "=SUM(A1;H7;U7)" and apply it like

ActiveSheet.Cells(y + k + 1, x + 1).Value = sValue
ActiveSheet.Cells(y + k + 1, x + 1).Text = sValue
ActiveSheet.Cells(y + k + 1, x + 1).Formula = sValue

and the all give an "object error"

why????
 
R

Richard Schollar

Hi

You should use the Formula property, not Value (and certainly not Text,
which is read only).

Try removing the semi-colons from the string and replacing with commas (even
though I presume your excel version uses ; in formulas). So sValue becomes:

sValue = SUM(A1,H7,U7)


Richard
 
J

jodleren

Hi

You should use the Formula property, not Value (and certainly not Text,
which is read only).

Try removing the semi-colons from the string and replacing with commas (even
though I presume your excel version uses ; in formulas).  So sValue becomes:

sValue = SUM(A1,H7,U7)

Thanks, that's helped
 

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