Hi Andy,
Without using VBA, I think I found a way to do what you want. However, this
method will need to use a helper column.
Using column K in my example,
In K1 enter:
=IF(A1="","",IF(A1=$C$1,1,0))
Then in K2, enter:
=IF(A2="","",IF(A2=$C$1,1,0)+K1)
Copy K2 down as far as needed.
Column K is your helper column.
Now you can use this formula (below) to get your results for the last two
games played with C1 being the team name you want the results for.
=IF(COUNTIF(A:A,C1)<2,SUMIF(INDIRECT("A1:A" &
COUNTA(A:A)),C1,INDIRECT("B1:B" &
COUNTA(A:A))),INDIRECT("B"&MATCH(COUNTIF(A:A,C1),INDIRECT("K1:K"
&COUNTA(A:A)),0))+INDIRECT("B"&MATCH(COUNTIF(A:A,C1)-1,INDIRECT("K1:K" &
COUNTA(A:A)),0)))
HTH,
Paul
Thanks Paul. Yes, I definitely need more than 3 games. It needs to
work no matter how many games have been played. I hope you or someone
has a solution, cuz I'm stuck.
PCLIVE said:
Ok, that only works if there were no more than three games played.
Additionally, if two or less were played, the formula had to be modified
as
follows.
=IF(COUNTIF(A:A,C1)>2,SUMIF(INDIRECT("A"&(MATCH(C1,A:A,0)+1)&":A"&COUNTA(A:A)),C1,INDIRECT("B"&(MATCH(C1,A:A,0)+1)&":B"&COUNTA(A:A))),SUMIF(INDIRECT("A1:A"
& COUNTA(A:A)),C1,B:B))
However, this still doesn't work if more than three games were played.
Maybe someone else can have a go at it.
Good luck.
Paul
Ok.
With C1 as the team name you want the last two game totals, try this:
=IF(COUNTIF(A:A,C1)>2,SUMIF(INDIRECT("A"&(MATCH(C1,A:A,0)+1)&":A"&COUNTA(A:A)),C1,INDIRECT("B"&(MATCH(C1,A:A,0)+1)&":B"&COUNTA(A:A))),SUMIF(INDIRECT("A1:A"
& COUNTA(A:A)),C1))
HTH,
Paul
I'm sorry for being so confusing here. Rather than responding to your
message, let me just restate my problem.
My spreadsheet contains the following 2 columns [Animal} and [Points},
with the following data that will be expanded. Suppose each animal
plays a game, so in the following chart 9 games have been played. In
the first game, Monkey scored 10 points; in the next game Gorilla
scosred 20 point.
[Animal] [Points}
Monkey 10
Gorilla 20
Dog 30
Monkey 15
Dog 20
Cat 10
Monkey 30
Gorilla 20
Gorilla 30
I am looking to find out how many points Gorilla scored in the last 2
games that Gorilla played. In this case, the answer would be 50. If
the variable was Monkey, instead of Gorilla, the answer would be 45.
I need a formula that finds the last 2 scores for the animal I am
analyzing.
Thanks again.
PCLIVE (RemoveThis) 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"&COUNTA(A:A)),B:B)
For the second to last entry in column A:
=SUMIF(INDIRECT("A1:A"&COUNTA(A:A)),INDIRECT("A"&COUNTA(A:A)-1),B:B)
HTH,
Paul
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?