View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
PCLIVE PCLIVE is offline
external usenet poster
 
Posts: 1,311
Default Need help with formula

Ok. I guess what was confusing is that there are three entries in column A
that contain "abc". If you add the corresponding numbers for all three,
then the total would be 7. Since you confirmed the total should be 4, then
I have to assume that you do not want to count the value next to the last
entry. Is that correct?
If so, then maybe:
=SUMIF(INDIRECT("A1:A"&COUNTA(A:A)-1),INDIRECT("A"&COUNTA(A:A)),B:B)

Another thing that was confusing is that the next to the last entry in
column A, is "def". Based on your original explanation and example, it
would appear that you were saying that the next to last entry in column A
should be "xyz".
=SUMIF(INDIRECT("A1:A"&COUNTA(A:A)-2),INDIRECT("A"&COUNTA(A:A)-1),B:B)

Key questions:
-Will only the last two entries be searched?
-Should either of the numbers next to those last two entries be included in
the total? I'm thinking no.
-Was the next to last entry in your example supposed to be "xyz"?

I think the above formulas may work for you.

HTH,
Paul

wrote in message
ups.com...
No, I have it right; probably just didn't explain it well enough. For
the "abc" example, I want the formula to add the appropriate amount in
column B for the latest 2 references to "abc". So in my example below,
the latest abc reference refers to 3 in column B. The immediately
preceding reference to "abc" refers to 1 in column B. 3+1 = 4 and
thats the result that would be accurate.

On Nov 27, 3:42 pm, "PCLIVE" wrote:
I'm not sure the example you've given is correct. If you total the
numbers
in column B for "abc" from column A, then the total should be 7. I'm
guessing this is what you want. If 7 is the correct answer, then maybe:

=SUMIF(INDIRECT("A1:A"&COUNTA(A:A)),INDIRECT("A"&C OUNTA(A:A)),B:B)

For the second to last entry in column A:

=SUMIF(INDIRECT("A1:A"&COUNTA(A:A)),INDIRECT("A"&C OUNTA(A:A)-1),B:B)

HTH,
Paul

wrote in
oglegroups.com...

Suppose you have 2 columns of data. Data gets added to the columns
frequently.


A B
xyz 4
abc 3
jkl 5
xyz 2
abc 1
def 4
abc 3


I need to calculate the total number in column B for the last 2
entries. Thus, if looking for "abc", the answer would be 4 (3+1),
since the abc got a 3 the last entry and 1 for the previous entry.
Using the same formula for xyz would return 6 (2 +4).


Any ideas on how I can accomplish this?