What have the clients NOT purchased?

pocquet

Board Regular
Joined
Aug 21, 2013
Messages
116
Hi Guys,

Been a while.

Got one that I cant quite get right in my head how to do it.

I have a list of clients and the products they have purchased.

Client table:

Client NameProductsUsersFee
MrPROD15100
MrPROD21100
MrPROD33100
ExcelPROD15100

<tbody>
</tbody>


Prod Table:

ProductDescription
Prod1Cats
Prod2Dogs
Prod3Bees

<tbody>
</tbody>


So Product table size is actually 100 products and Clients will be over 100k rows but this will be split so no issues.

What I want to do is find out what products the clients Have Not purchased.

Any ideas?

Thanks

Poc
 

Some videos you may like

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Special-K99

Well-known Member
Joined
Nov 7, 2006
Messages
8,341
in ProdTable!C2
=IF(COUNTIF(ClientTable!B$2:B$5,A2)=0,"NOT PURCHASED","")

copy down the column
 

pocquet

Board Regular
Joined
Aug 21, 2013
Messages
116
HI K99,

Thanks for this, Not quite what I am after however.

The result I want is Client name, Not purchased.

I have a funny feeling I cant do this unless I am in a database, no issue there but was hoping to do it in excel to make it easy to deploy
 

Special-K99

Well-known Member
Joined
Nov 7, 2006
Messages
8,341
So specifically you want a list of clients with a list of products they have not purchased?
That's a bit more complicated, a Pivot table or Power Query may solve this but I dont know much about tat part of Excel.
 

pocquet

Board Regular
Joined
Aug 21, 2013
Messages
116
So specifically you want a list of clients with a list of products they have not purchased?
That's a bit more complicated, a Pivot table or Power Query may solve this but I dont know much about tat part of Excel.
Yeah thats exactly it :)

Not sure its possible tbh without plugins
 

sandy666

Well-known Member
Joined
Oct 24, 2015
Messages
4,672
Could you post expected result (as mentioned in post#5 also)?
 

pocquet

Board Regular
Joined
Aug 21, 2013
Messages
116
Could you post expected result (as mentioned in post#5 also)?
Sorry,

Client NameProduct Not Purchased
ExcelProd2
Excelprod3

<tbody>
</tbody>

SO we know that the first client has purchased all 3 products, given in the example there are only 3 products they would be completely excluded, but the second has NOT purchased the 2nd and 3rd product so I would want/expect to see two entry.
 

MickG

MrExcel MVP
Joined
Jan 9, 2008
Messages
14,841
With your Client names starting "A2" and Related products starting "B2".
Try this for product in Row 1 starting "F1" with "Not Bought" items in rows below each "Product Name" .
Code:
[COLOR="Navy"]Sub[/COLOR] MG25Apr55
[COLOR="Navy"]Dim[/COLOR] Ray [COLOR="Navy"]As[/COLOR] Variant, K [COLOR="Navy"]As[/COLOR] Variant, nStr [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]String,[/COLOR] n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Ac [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Sp [COLOR="Navy"]As[/COLOR] Variant
Ray = Range("A2", Range("B" & Rows.Count).End(xlUp))

[COLOR="Navy"]With[/COLOR] CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
[COLOR="Navy"]For[/COLOR] n = 1 To UBound(Ray, 1): .Item(Ray(n, 2)) = Empty: [COLOR="Navy"]Next[/COLOR]

  [COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] K [COLOR="Navy"]In[/COLOR] .keys
       [COLOR="Navy"]For[/COLOR] n = 1 To UBound(Ray, 1)
          [COLOR="Navy"]If[/COLOR] Not K = Ray(n, 2) [COLOR="Navy"]Then[/COLOR]
              nStr = nStr & IIf(nStr = "", Ray(n, 1), ", " & Ray(n, 1))
             [COLOR="Navy"]End[/COLOR] If
          [COLOR="Navy"]Next[/COLOR] n
              .Item(K) = nStr: nStr = ""
        [COLOR="Navy"]Next[/COLOR] K

Ac = 5
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] K [COLOR="Navy"]In[/COLOR] .keys
    Ac = Ac + 1
    Cells(1, Ac) = K
    Sp = Split(.Item(K), ", ")
    Cells(2, Ac).Resize(UBound(Sp) + 1).Value = Application.Transpose(Sp)
[COLOR="Navy"]Next[/COLOR] K
[COLOR="Navy"]End[/COLOR] With
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 

pocquet

Board Regular
Joined
Aug 21, 2013
Messages
116
With your Client names starting "A2" and Related products starting "B2".
Try this for product in Row 1 starting "F1" with "Not Bought" items in rows below each "Product Name" .
Code:
[COLOR=Navy]Sub[/COLOR] MG25Apr55
[COLOR=Navy]Dim[/COLOR] Ray [COLOR=Navy]As[/COLOR] Variant, K [COLOR=Navy]As[/COLOR] Variant, nStr [COLOR=Navy]As[/COLOR] [COLOR=Navy]String,[/COLOR] n [COLOR=Navy]As[/COLOR] [COLOR=Navy]Long,[/COLOR] Ac [COLOR=Navy]As[/COLOR] [COLOR=Navy]Long,[/COLOR] Sp [COLOR=Navy]As[/COLOR] Variant
Ray = Range("A2", Range("B" & Rows.Count).End(xlUp))

[COLOR=Navy]With[/COLOR] CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
[COLOR=Navy]For[/COLOR] n = 1 To UBound(Ray, 1): .Item(Ray(n, 2)) = Empty: [COLOR=Navy]Next[/COLOR]

  [COLOR=Navy]For[/COLOR] [COLOR=Navy]Each[/COLOR] K [COLOR=Navy]In[/COLOR] .keys
       [COLOR=Navy]For[/COLOR] n = 1 To UBound(Ray, 1)
          [COLOR=Navy]If[/COLOR] Not K = Ray(n, 2) [COLOR=Navy]Then[/COLOR]
              nStr = nStr & IIf(nStr = "", Ray(n, 1), ", " & Ray(n, 1))
             [COLOR=Navy]End[/COLOR] If
          [COLOR=Navy]Next[/COLOR] n
              .Item(K) = nStr: nStr = ""
        [COLOR=Navy]Next[/COLOR] K

Ac = 5
[COLOR=Navy]For[/COLOR] [COLOR=Navy]Each[/COLOR] K [COLOR=Navy]In[/COLOR] .keys
    Ac = Ac + 1
    Cells(1, Ac) = K
    Sp = Split(.Item(K), ", ")
    Cells(2, Ac).Resize(UBound(Sp) + 1).Value = Application.Transpose(Sp)
[COLOR=Navy]Next[/COLOR] K
[COLOR=Navy]End[/COLOR] With
[COLOR=Navy]End[/COLOR] [COLOR=Navy]Sub[/COLOR]
Regards Mick

Thanks allot Mick that works great.
 

Forum statistics

Threads
1,089,431
Messages
5,408,179
Members
403,188
Latest member
Sanjana Ramesh

This Week's Hot Topics

  • help please
    SORRY NOT ANY GOOD AT EXCEL SO HELP WOULD BE MUCH APPRECIATED this formula is in a sheet called ignore...
  • two formulas needed
    Hello, I'll try my best to explain this: First formula needed in Sheet1 cell A2: If Sheet1 cell B2 = Sheet2 cell B2 then return a 1. If not then...
  • Dynamic Counts
    Good afternoon, we are tidying up some data & the data seems to be growing quicker than we are tidying it up! What we confirm (by reviewing it...
  • Help Excel formula eliminate duplicate values and keep only 2 identical rows.
    as picture below column A has a duplicate value. but the values are not the same as the rule. sometimes 4 rows, sometimes 10 rows or 7 or 9...
  • Macro Compile Error Sub or Function not defined
    Hello, I am trying to run macros from a validation list, all macros have been created and run perfectly on there own but I'm getting a compile...
  • Last row combined with Current Region VBA
    I'm generally happy finding the last row of data through something like Lastrow = Cells(Rows.Count, "D").End(xlUp) but I don't always receive data...
Top