Sum row totals for multiple items in a worksheet

M

Mikey

How do I add all the numbers above a cell using generic range references and
then be able to move down the column and repeat the Sum function for all
records in the worksheet? There are way too many to do each manually. I can
get the macro to go to the cells where I want the Sum Totals but don't know
the code to "sum up" the values above that cell. I'v tryed the xlUp etc but
it gives me specific ranges each time. Suggestions are much appreciated.
 
B

Bernard Liengme

I am not clear on the question. Would you like to elaborate?
best wishes
 
M

Mikey

I have expenses for numerous wells in a spreadsheet. There are many other
items included that are not expneses. I have a "Category" column to identify
the Expense rows with a Total line below them. I want to Total the expenses
for each well and move down the rows to the next Total line then sum all the
expenses above it. I can get my macro to goto the cell where I want the
total but don't have the skill set to produce a Sum function that adds as
many lines above the cell until it hits a blank cell at the top of the data
in the column. This is what I have that shows specific ranges (K14:K53) with
the Total for the cells in K53 and I need to have generic ones so I can
repeat the Sum formula for each well. There are different numbers of expense
rows for each well.

Range(Selection, Selection.End(xlUp)).Select
Range(Selection, Selection.End(xlUp)).Select
Range("W14:W53").Select
Range("W53").Activate
ActiveCell.FormulaR1C1 = "=SUM(R[-39]C:R[-1]C)"
Range("W14:W53").Select
Range("W53").Activate The formula gives the total in this cell
 

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

Top