Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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, |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have following code, but I got run time error 1004.
Application Defined or Object defined error. Sheets(wsDestination).Cells(I, eColumn).Formula = "=SUM(G" & I & ":" & Chr(eColumn + 40) & I & ")" "Souris" wrote: 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, |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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, |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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, |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dim rw As Long
rw = 12 'the row number you want in formula For I = 1 to 50 Sheets(wsDestination).Cells(I, eColumn).Formula = "=SUM(C& rw:F& rw)" rw = rw + I Loop Mike F "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, |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how do I write a formula to copy text from one cell to another? | Excel Worksheet Functions | |||
how do I write a formula: if (cell address) is less than X add Y | Excel Discussion (Misc queries) | |||
How do you write an excel formula to sum data in every second cell | Excel Worksheet Functions | |||
How can I write an if-then formula for 0 or less than 0 in cell t. | Excel Worksheet Functions | |||
Question: Cell formula or macro to write result of one cell to another cell | Excel Programming |