how to use the =sum function

  • Thread starter Thread starter Warura
  • Start date Start date
W

Warura

I am trying to make a Sum of some set of cells, but are not always i
the same position, I have this code.... am I missing somthin
:confused:

Cells(irun.Row, ultima) = "=Sum(cells(" & po1 & "," & ultima
"):cells(" & (irun.Row - 1) & "," & ultima & "))"

This does put the text "=Sum(cells(20,1):cells(25,1)" on the cell i
the sheet, but it doesnt sum the cells.... or what can i do? I cant us
specific cells cause I am geting information from diferent ranges.....
:
 
Try this

Cells(irun.Row, ultima).Formula = "=Sum(" & cells(po1,ultima).address &
":" & cells(irun.Row - 1,ultima ).Address & ")"


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Quite often I find people use code when some smart functions on a sheet will
suffice (or at least simplify the code a lot.) Try this:

=SUM(OFFSET(RC,-1,0):INDIRECT("Top"&COLUMN(RC)))

All you need to do is define a named cell called "Top1", "Top2", etc, for
each column you want to create the sum for and the above sum function does
not need to be changed. Redefine the name and the formula automatically works
out the new sum.

James.

P.S . I use R1C1 because A1 is awful - R1C1 is so much more verifiable and
understandable once you get used to it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top