Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sum based on condition / cell value change....

Status
Not open for further replies.

z07924

IS-IT--Management
Feb 18, 2002
122
GB
Say, sheet1 has 5 columns and 10 rows. I want to calculate sum of each column based on some other field. for e.g.,

Worksheets("sheet2").Range("E34") = "AB" or Worksheets("sheet2").Range("E34") = "CD"
{
....
do the sum
....
}

My question is this...

WHENEVER a cell value changes the corresponding sum should be recalculated once you leave the cell...how do I do that?
I have 5 different columns and each column has 10 rows...

can someone please help....thanks.
 

You can do this within the worksheet itself:

pick any cell and enter this (or something like this)... let's say your data is in the range A1:D10 and you are wanting the sum for column D if cell A has "AC" in it.

=sumif(A1:a10,"AC",D1:D10)

Now any time the cells change this equation will update as long as you calulate or leave calculation on.
 
Thanks for responding. Sorry I may not have stated the problem clearly. Let me try it again...

Say, I have data in A1:A10. I want to sum this data and multiply the sum by a number based on three conditions from another sheet..

If Worksheets("external").Range("E34") = "AB" OR Worksheets("external").Range("E34") = "CD" OR Worksheets("external").Range("E34") = "EF"

Worksheets("original").Range("A11").value = 0.625 * sum(A1:A10)

How do I do this? I want to attach this macro/vba to cell change event so that whenever data in A1:A10 changes, A11 will be recalculated...

thanks for any help...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top