CountIf & Vlookup Combinatoin

sc0ttish

New Member
Joined
Aug 22, 2007
Messages
37
Office Version
  1. 365
Hello everyone,

I've trying to set up a formula, which i thought would be easy but seem to be stuck.

My spreadsheet has two worksheets House List & Brandcount

House List has the account number in column C and the account number in the Brandcount is in column A.
In the Brandcount worksheet in column B is a list of brands purchased (Brand 1, Brand 2, Brand 3, Brand 4, Brand 5)

What i wanted to do is in House List is in column F count the brands purchased by each account number, is:
Account 12345 , 3 brands

I've tried using a combination of countif and vlookup but not getting far.

Can someone point me in the right direction.
Thanks
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Ok so this will work but you have to have the brand your looking for in one of the columns in House list also so I have just put this in column D
Excel Formula:
=COUNTIFS(Brandcount!A:A,'House List'!C2,Brandcount!B:B,'House List'!D2)
 
Upvote 0
Book1
ABCDEF
1
21Brand20
32Brand21
43Brand20
54Brand20
65Brand21
76Brand20
House List
Cell Formulas
RangeFormula
F2:F7F2=COUNTIFS(Brandcount!A:A,'House List'!C2,Brandcount!B:B,'House List'!D2)
 
Upvote 0
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
Ok so this will work but you have to have the brand your looking for in one of the columns in House list also so I have just put this in column D
Excel Formula:
=COUNTIFS(Brandcount!A:A,'House List'!C2,Brandcount!B:B,'House List'!D2)

Thanks @EFANYoutube , sorry maybe should have included some more data.
I am looking for the cells in column F to have the total number of brands stocked out of all the brands we can supply.
Not a count of separate brands.

This is an example of my master list.
ABCDEF
PlanAccount 112345623/12/2021Name
PlanAccount 213456704/01/2022Name
PlanAccount 315964709/01/2022Name
PlanAccount 415649131/01/2022Name
PlanAccount 513641215/01/2022Name

This is an example of the Brandcount sheet
AB
123456Brand 1
123456Brand 1
123456Brand 3
123456Brand 1
159647Brand 1
159647Brand 2
136412Brand 3
136412Brand 3
136412Brand 3
136412Brand 3

So my expected return for account 123456 would be 2, as they have bought Brand 1 and Brand 3 (although they have bought Brand 1 three times that doesnt matter).
Account 159647 would also be 2 but Account 136412 would be 1 as they bought Brand 3 four times but its only 1 brand purchased.

Hope this makes sense.
Thanks for the help
 
Upvote 0
How about
+Fluff 1.xlsm
ABCDEF
1
2PlanAccount 112345623/12/2021Name2
3PlanAccount 213456704/01/2022Name0
4PlanAccount 315964709/01/2022Name2
5PlanAccount 415649131/01/2022Name0
6PlanAccount 513641215/01/2022Name1
7
8
9
10
11123456Brand 1
12123456Brand 1
13123456Brand 3
14123456Brand 1
15159647Brand 1
16159647Brand 2
17136412Brand 3
18136412Brand 3
19136412Brand 3
20136412Brand 3
Main
Cell Formulas
RangeFormula
F2:F6F2=IFERROR(ROWS(UNIQUE(FILTER($B$11:$B$20,$A$11:$A$20=C2))),0)
 
Upvote 0
How about
+Fluff 1.xlsm
ABCDEF
1
2PlanAccount 112345623/12/2021Name2
3PlanAccount 213456704/01/2022Name0
4PlanAccount 315964709/01/2022Name2
5PlanAccount 415649131/01/2022Name0
6PlanAccount 513641215/01/2022Name1
7
8
9
10
11123456Brand 1
12123456Brand 1
13123456Brand 3
14123456Brand 1
15159647Brand 1
16159647Brand 2
17136412Brand 3
18136412Brand 3
19136412Brand 3
20136412Brand 3
Main
Cell Formulas
RangeFormula
F2:F6F2=IFERROR(ROWS(UNIQUE(FILTER($B$11:$B$20,$A$11:$A$20=C2))),0)
Thanks @Fluff

Formula looks great, but its not giving me the expected results for some reason.
Its giving me a 0 result in all the cells in column F, then where there is no account number in Column C its giving me a 1.

Not sure if i'm being silly, but tried putting the date into a new sheet and changed the formula with the new sheetname but still the same?
 
Upvote 0
In that case check that all your account numbers on both sheets are either text or numbers, but not a mix of both
 
Upvote 0
In that case check that all your account numbers on both sheets are either text or numbers, but not a mix of both
@Fluff
Proper school boy error, fantastic.

One last question.
When there is no account number in column C it returns a '1' result. How do i stop this?
 
Upvote 0
How about
Excel Formula:
=IF(C2="","",IFERROR(ROWS(UNIQUE(FILTER($B$11:$B$200,$A$11:$A$200=C2))),0))
 
Upvote 0
Solution

Forum statistics

Threads
1,214,376
Messages
6,119,179
Members
448,871
Latest member
hengshankouniuniu

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