VBA to count

sashaP

New Member
Joined
Jul 19, 2019
Messages
8
cm
brand 12
brand 41
brand 41
brand 13
brand 7 1

<tbody>
</tbody>


I need to count quantity of the brands , there are many brands numbers in the list.using new excel.
The result should be brand 1 = 5 brand 4 = 2 brand 7 = 1

Thanks ! :)
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hey,

=SUMPRODUCT(($C$2:$C$6="brand 1")*($M$2:$M$6))

Assuming brand names in Col C (rows 2 - 6) & the quantity in Col M (rows 2 - 6)

NB: You can change "brand 1" to be more dynamic by making a cell as "brand 1" and referencing the cell.
 
Upvote 0
Another way
=SUMIF(C:C,"Brand1",M:M)
 
Upvote 0
Hey,

=SUMPRODUCT(($C$2:$C$6="brand 1")*($M$2:$M$6))

Assuming brand names in Col C (rows 2 - 6) & the quantity in Col M (rows 2 - 6)

NB: You can change "brand 1" to be more dynamic by making a cell as "brand 1" and referencing the cell.


I got error value.....
There are many brands i want to count isn't it possible not to type the brands ?
 
Upvote 0
Like


Book1
CDEFGHIJKLMNOP
2cm
3brand 12brand 15
4brand 41brand 42
5brand 41brand 71
6brand 13
7brand 71
Sheet1
Cell Formulas
RangeFormula
P3=SUMIF(C:C,O3,M:M)
 
Upvote 0
Like

CDEFGHIJKLMNOP
2cm
3brand 12brand 15
4brand 41brand 42
5brand 41brand 71
6brand 13
7brand 71

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
P3=SUMIF(C:C,O3,M:M)

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>

Yes that's what i need but i get results of 0
 
Upvote 0
Are the quantities stored as Numbers?

It may be the case that they are Text or prefixed with an apostrophe - in which the formula @Fluff wrote will return 0 as you have said has happened
 
Upvote 0
Also make sure that your entries in columns C and O match EXACTLY.
Any extras spaces in one and not the other will cause it NOT to match, and return 0s.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,485
Messages
6,113,931
Members
448,533
Latest member
thietbibeboiwasaco

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