View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default placing formula in cells

Hi Terry,

In your fomula change each instance of "off" to ""off"", i.e. double up the
quotes.

As written, your formula will return a circular reference.

If you explain the formula that you need, I am sure that your code can be
simplified


---
Regards,
Norman



"Terry V" wrote in message
...
Hello
I know this probably sounds like a really silly question, but Ive been
racking my brains trying to figure it out.

I have a Workbook_Open() , so that when the workbook opens, it controls
scrolling.

I also need to place a formula in several cells.
My problems are these:
I have a range - C7:E26 that I need to add a formula to.

In the for loop, Im trying to go to each cell in the range:
Dim rng as range
Dim cl
Dim r as range
Set rng = range("C7:E26")
For each cl in rng
set r = range(cl.address)
range(r).formula = "=IF(" & Range(r) & "="Off","Off","")"
Next cl

Now, I know where the problem lies, and it is in the "". This is
something
that has plaqued me for quite a while.
The other problem is that "set r = range(cl.address)" returns a value not
a
range object.

How can I fix this?

Thank you
Terry