View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
BEVERNON BEVERNON is offline
external usenet poster
 
Posts: 2
Default Newbie in deep..... Excel and VB

Hi everyone.
I'm an experienced programmer, just not experienced with Excel and VB. I have
to populate a spread sheet programmatically. On a button click, I am clearing
the worksheet, and then I compute a formula that goes into each cell. It
doesn't work!

This is what I'm doing (snipped somewhat)

Dim myFormula as string

....

myFormula = "=A1+B1"
cells(10, 10).formula = myFormula

..... that works.

So does.... cells(10,10).formula = "A1+B1"

Now if I need to compute the formula at runtime like this....
Let x=1
Let y=1
myFormula = "=A"+str(x)+"+B"+str(y)
and try cells(10, 10).formula = myFormula I get an error.

In each case the value of myFormula is "=A1+B1"

Anybody ever tried dynamically computing a formula and assigning it to a cell?

I've been working on XL for the past week, and have been very impressed with
the capabilities, but before I can become a true believer I need to know how to
do this...

Similarly, how can I dynamically compute a range? I would like to pass a
computed string to a statement like this:

range(mycomputedstring).formula = myFormula

Thanks in advance for your help.

Brad Vernon
Help!