Sum all values using IF function

  • Thread starter Thread starter girth69
  • Start date Start date
G

girth69

I have a list full of information on my sheet. One column displays a
department number and another column displays a number of hours that
this department has worked.

I need to sum together all the hours of a certain department to get an
overall total.

e.g.

Dept Number Number of Hours
151 4
151 4
151 1
132 6
132 2
151 4
144 8
144 3
132 1

How do i sum all the numbers of hours for department 151?? im assuming
its an IF statement??
 
Hi there

Try this ,it may be helpful though not so good looking

Sub sumfig()
Dim r as integer
Dim s as integer
For r= 1 to 9 (kt's the number of departments)
if cells(r,1).value = 151 then
s=s+cells(r,2).value
endif
next
' to show the result of sum of the hours
cells (12,1).value =s
end sub
 

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

Similar Threads

SUM IF function HELP!!! 3
IF, AND & OR 3
How to use date range to sum multiple columns 8
sum for each group 1
if function help 5
Sum multiple lookup values 7
Struggling with Sumproduct 4
Embedded If Limitation 10

Back
Top