View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Souris Souris is offline
external usenet poster
 
Posts: 107
Default write a formula to a cell using VBA

Thanks millions,

It works,




"Norman Jones" wrote:

Hi Souris,

Try:

Sub TesterA()
Dim I As Long

For I = 1 To 3
Sheets(wsDestination).Cells(I, eColumn).Formula = _
"=SUM(C" & I + 11 & ":F" & I + 11 & ")"
Next I

End Sub


---
Regards,
Norman



"Souris" wrote in message
...
I wnated to write a simple formula like "=SUM(C12:C18)" in to a cell using
VBA.

I have following code

Sheets(wsDestination).Cells(I, eColumn).Formula = "=SUM(C12:C18)"

The problme is I have the code in a for loop and I need change the cells
depends on the for loop index like

when I = 1 then "=SUM(C12:F12)"
when I = 2 then "=SUM(C13:F13)"
when I = 3 then "=SUM(C14:F14)"

The C and F depend on a variable to control.

Any information is great appreciated,