How to consolidate non consecutive numbers in a column?

excelos

Well-known Member
Joined
Sep 25, 2011
Messages
594
Office Version
  1. 365
Platform
  1. Windows
Hello

I want to consolidate (sum) the consecutive only numbers in a column (i.e. if numbers are non consecutive, then they should not be added).

For example, in the below table:


Column AColumn B
K
3​
K
2​
K
K
3​
K
K
4​
L
2​
L
1​
L
2​
L
L
3​

I need to consolidate/sum:
For K in Column A, the cells B2, B3 together and no other cell (as they are not consecutive).
For L in Column A, the cells B8, B9, B10 no and other cell (as they are not consecutive).

The table then would look like below, if we put the consolidated numbers (sums) into Column C

Column AColumn BColumn C
K
3​
5​
K
2​
5​
K
K
3​
K
K
4​
L
2​
5​
L
1​
5​
L
2​
5​
L
L
3​

Any neat way for this? Even with pivot!
Thanks!
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
what if there are multiple sets of consecutive numbers for a (or some) groups?
 
Upvote 0
Try this:

Book1
ABC
1
2K35
3K25
4K 
5K3 
6K 
7K4 
8L25
9L15
10L25
11L 
12L3 
Sheet1
Cell Formulas
RangeFormula
C2:C12C2=IF(B2="","",IF(AND(A2=A1,B1<>""),C1,IF(AND(A2=A3,B3<>""),SUM(B2:INDEX(B2:B1000,MATCH(0,(B2:B1000<>"")*(A2:A1000=A2),0))),"")))
 
Upvote 0
IN C2
Excel Formula:
=LET(a,A2:A12,b,B2:B12,c,IF(b<>"",IF((ABS(B3:B13-B2:B12)=1)+(ABS(B1:B11-B2:B12)=1),1,0),""),MAP(a,c,LAMBDA(x,y,IF(y=1,SUM(b*(x=a)*(c=1)),""))))
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top