ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   setting formula property (https://www.excelbanter.com/excel-programming/276435-setting-formula-property.html)

Ed Stevens

setting formula property
 
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.

Tom Ogilvy

setting formula property
 
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


--
Regards,
Tom Ogilvy



Ed Stevens wrote in message
om...
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.





All times are GMT +1. The time now is 05:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com