Three solutions:
(I’m assuming that your data are in cells A1:B22.)
1. Conditional Formatting
- Set
C1 to =B1.
(If your data don’t begin in column 1,
and the row before the first data row doesn’t have numbers in it,
you can use the next formula for the entire column.)
- Set
C2 to =IF(A1=A2, C1+B2, B2) and drag/fill down to C22.
This will set column C to be a running total for the matching numbers;
i.e., C1 = 50, C2 = 220, C3 = 320, C4 = 900, C5 = 500, etc.
- Select the results (i.e., cells
C1:C22)
and do “Conditional Formatting” → “New Rule”.
Select “use a formula to determine which cells to format”,
enter formula =A1=A2, and format the cell to be invisible.
(Common ways of doing this are to set the font color to white
or to apply a custom number format of ;;;.)
In case the above isn’t clear:
This puts a number in every cell in the range,
but just hides the ones you don’t want.
2. Helper Column
- Pick a column that’s out of the way; for example, column
Z.
Define it the same as we defined column C, above.
- Set
C1 to =IF(A1=A2, "", Z1) and drag/fill down to C22.
3. All-in-One
- Set
C1 to =IF(A1=A2, "", SUMIF(A$1:A$22, A1, B$1:$B22))
and drag/fill down to C22.
Note that, if the phone numbers are not sorted properly,
and are not divided into unique groups,
these methods produce different results.
Labeling the methods as follows:
- Conditional Formatting
- Helper Column
- All-in-One
consider these data:
phone value method1 method2 method3
︙ ︙ ︙ ︙ ︙
95 800 1500 1500 1500
42 1 ← First block of data for phone # 42
42 2 3 3 99 ← Note that methods 1 and 2 yield 1 + 2 = 3
17 4 ↖ but method 3 yields 1 + 2 + 32 + 64 = 99
17 8
17 16 28 28 28
42 32 ← Second block of data for phone # 42
42 64 96 96 99 ← Note that methods 1 and 2 yield 32 + 64 = 96
83 1000 ↖ but method 3 yields 1 + 2 + 32 + 64 = 99
83 2000 (again)
83 4000 7000 7000 7000
︙ ︙