You are here:

# Excel/Macro to sum different rows & get result in next column

Question
QUESTION: Hi

I want to sum of materials issued to a student & data are in different rows & i want the sum total in next column.See for example.My data is like as
Student no MaterialIssued  Rate   Totalper student
456          pencil         10      30(here i want the total)
eraser         20
In above case a student has taken only two materials might there will be more items taken by another student.Hence the no of rows are not fixed.

Kindly help me out if there is nay macros to get total cost per student as of now i am doing the totalling by manually in excel.

Please tell me, do you have one student per spreadsheet or do you have all of the students listed under each other, on the same spreadsheet?

Thank you - Andrea

---------- FOLLOW-UP ----------

QUESTION: I have all the students in a single spreadsheet listed one on another.

Abdul -

You can use the SUMIF() function for this. Expand the student numbers for all purchases:

student#  item purchased     cost   total
456       pencil          .10
456       paper          1.00

123       pencil          .10
123       ruler          .50

Now you want to use SUMIF(RANGE,CRITERIA,SUM_RANGE)- RANGE is the cells that contain your criteria, in your case the student#. CRITERIA is the student number, and SUM_RANGE is the cells that have the numbers you want to add. Sometimes SUM_RANGE is the same as RANGE.

The function searches for the student# and sums anything that meets the criteria (notice that the function is identical, except the criteria it is searching for):

student#  item purchased     cost   total
456       pencil          .10   =SUMIF(A:A,"456",C:C)
456       paper          1.00

123       pencil          .10   =SUMIF(A:A,"123",C:C)
123       ruler          .50

It should be an easy adaption - Andrea
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

#### Andrea Lynch

##### Expertise

I am very familiar with teaching excel concepts, and formulas. I am not as capable with VBA questions.

##### Experience

I currently tutor in this area. I worked for four years developing curriculum and teaching Microsoft applications to adult audiences. I also previously volunteered for allexperts.com.

Education/Credentials
BA, English, Western Washington University Certificates in C Programming, ASP.NET, VisualBasic.NET, University of Washington Extension

Awards and Honors
Rated in the top ten instructors (national), New Horizons Computer Learning Center.