Tricky Sort / Batch Count

Lukums

Board Regular
Joined
Nov 23, 2015
Messages
195
G'day!

I currently have : =SUM(IF(FREQUENCY(A8:A1000,A8:A1000)>0,1))

It batches column A with re-occurring values and gives the number of batches this works great!

However, I now want to look at column H:H and see how many batches from A:A have the value "MG" in column B.

See example below:

[TABLE="width: 500"]
<tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]1000[/TD]
[TD]mg[/TD]
[/TR]
[TR]
[TD]1000[/TD]
[TD]mg[/TD]
[/TR]
[TR]
[TD]2500[/TD]
[TD]sg[/TD]
[/TR]
[TR]
[TD]1500[/TD]
[TD]mg[/TD]
[/TR]
[TR]
[TD]1500[/TD]
[TD]mg[/TD]
[/TR]
[TR]
[TD]3000[/TD]
[TD]sg[/TD]
[/TR]
[TR]
[TD]3800[/TD]
[TD]hr[/TD]
[/TR]
</tbody>[/TABLE]

The solution would be to obtain the answer 2. As 1000 batch contain mg and 1500 contain mg.

Any ideas would be great.

Thanks all.

Luke
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
[TABLE="class: grid"]
<tbody>[TR]
[TD][/TD]
[TD]
A
[/TD]
[TD]
B
[/TD]
[TD]
C
[/TD]
[/TR]
[TR]
[TD]
1
[/TD]
[TD]
1000​
[/TD]
[TD]mg[/TD]
[TD]
2​
[/TD]
[/TR]
[TR]
[TD]
2
[/TD]
[TD]
1000​
[/TD]
[TD]mg[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
3
[/TD]
[TD]
2500​
[/TD]
[TD]sg[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
4
[/TD]
[TD]
1500​
[/TD]
[TD]mg[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
5
[/TD]
[TD]
1500​
[/TD]
[TD]mg[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
6
[/TD]
[TD]
3000​
[/TD]
[TD]sg[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
7
[/TD]
[TD]
3800​
[/TD]
[TD]hr[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

C1=SUM(IF(FREQUENCY(IF(B1:B7=B1,A1:A7),A1:A7),1)) control+shift+enter
 
Upvote 0
[TABLE="class: grid"]
<tbody>[TR]
[TD][/TD]
[TD]
A
[/TD]
[TD]
B
[/TD]
[TD]
C
[/TD]
[/TR]
[TR]
[TD]
1
[/TD]
[TD]
1000​
[/TD]
[TD]mg[/TD]
[TD]
2​
[/TD]
[/TR]
[TR]
[TD]
2
[/TD]
[TD]
1000​
[/TD]
[TD]mg[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
3
[/TD]
[TD]
2500​
[/TD]
[TD]sg[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
4
[/TD]
[TD]
1500​
[/TD]
[TD]mg[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
5
[/TD]
[TD]
1500​
[/TD]
[TD]mg[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
6
[/TD]
[TD]
3000​
[/TD]
[TD]sg[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
7
[/TD]
[TD]
3800​
[/TD]
[TD]hr[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

C1=SUM(IF(FREQUENCY(IF(B1:B7=B1,A1:A7),A1:A7),1)) control+shift+enter

Thanks for your speedy response!

This does work as you intended, but the values may not always be in this array, it could be any mg/sg/hr in B1 moving forward.
Correct me if I'm wrong but if this array changes it wouldn't work as it's only looking at B1? I'd need to it search the column to find all "mg" values which counts the batches in column A.

Please correct me if I'm wrong still very much a novice.
 
Upvote 0
C1=SUM(IF(FREQUENCY(IF(B1:B7=B1,A1:A7),A1:A7),1)) control+shift+enter

or
c1=SUM(IF(FREQUENCY(IF(B1:B7="mg",A1:A7),A1:A7),1)) control+shift+enter is the same formula
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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