setting formula property

  • Thread starter Thread starter Ed Stevens
  • Start date Start date
E

Ed Stevens

I could have sworn I asked this hear a year or so ago (and that's
about as often as I have to write some Excel macros), but a search of
the archives didn't turn it up. I'm also not able to find what I'm
looking for on MSDN, though I'm sure it can be done.

Need is to set a column total into a range of cells. This pseudo code
demonstrates what I'm after

for x = var1 to var2
myWorksheet.cells(row_num1, x).formula =
"sum((row_num2,x):(row_num3,x))"

next


basic point is I need the loop to step me from column to column, and
set up a sum of some rows in that column, but I won't know the column
by its letter name.
 
for x = var1 to var2
With myWorksheet
.cells(row_num1, x).formula = _
"=sum(" .Range(.Cells(row_num2,x),.Cells(row_num3,x)) _
.Address(0,0) & ")
End With
next
 
Back
Top