Formula to Group Companies under Categories

TaraAlexander

New Member
Joined
Jun 6, 2018
Messages
4
I have two excel lists.

List A
OrganizationCategory 1Category 2Category 3Category 4Category 5
Azure StandardBeans - CANNEDBeans - DRYBeet - CANNEDMixed Fruit - FROZENOnions - FROZEN
Basic American Foods, Inc.Potatoes: Russett - FROZENBeet - CANNEDGarlic - SPECIALTYPotatoes: Russett - FROZEN
Beaverton Foods, Inc.Onions - ORGANICGarlic - SPECIALTYPotatoes: Russett - FROZEN
Boardman Foods, Inc.Garlic - SPECIALTYMixed Fruit - FROZEN
Calbee North America, LLCPotatoes: Diced - FROZENPotatoes: Russett - FROZENOnions - WHOLE PEELED
List B
OrganizationCategory 1Category 2Category 3Category 4
Safe Quality Food Institute (SQFI)AGENCIES/ASSOCIATIONS: Associations/AgenciesFOOD SAFETY/SECURITY: HACCP/ISOFOOD SAFETY/SECURITY: Food Safety/SecurityTRAINING: Training & Education
Dorsey & Whitney LLPAGRICULTURE: Commodity SourcingAGRICULTURE: Seed DistributorsCONSULTING- BUSINESS SERVICES: Accounting/Tax/FinancialCONSULTING- BUSINESS SERVICES: Insurance & Risk Mgmt
Safe Quality Food Institute (SQFI)FOOD SAFETY/SECURITY: HACCP/ISOTRAINING: Training & Education
Dorsey & Whitney LLPAGRICULTURE: Seed DistributorsCONSULTING- BUSINESS SERVICES: Accounting/Tax/FinancialCONSULTING- HUMAN RESOURCES: Employee Benefits
A & K Development CompanyEQUIPMENT- CONVEYANCE/ BATCH PROCESSING: Conveyor Belts, Pulleys, Microrollers & VibratorsEQUIPMENT- CONVEYANCE/ BATCH PROCESSING: Conveyor Chain
GEM Equipment of Oregon, Inc.EQUIPMENT- CONVEYANCE/ BATCH PROCESSING: Conveyor Belts, Pulleys, Microrollers & VibratorsEQUIPMENT- PROCESSING: Berry Processing Syst.EQUIPMENT- GENERAL: Processing EquipmentEQUIPMENT- GENERAL: Packaging Equipment

<tbody>
</tbody>

Need a formula to group as below. There are 200+ categories & 100+ companies.

Beans - CANNEDBeet - CANNEDGarlic - SPECIALTYPotatoes: Russett - FROZEN
Azure StandardAzure StandardBasic American Foods, Inc.Basic American Foods, Inc.
Basic American Foods, Inc.Beaverton Foods, Inc.Beaverton Foods, Inc.
Boardman Foods, Inc.Calbee North America, LLC

<tbody>
</tbody>
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Hi
I don't see what List B has to do with what you are trying to achieve.

If you have Excel 2013 or above Use Get Data from Table for List A.
Select column A.
Select Unpivot other columns.
Delete the Category column.
Rename the last column as Products.
Save and Load data to Worksheet.
Summarize resulting table with Pivot Table and add Product to the Rows area, followed by Organisation.
 
Upvote 0
If you normalize your data, then you could create a Pivot Table that will resemble you requirements.

Here is code to normalize your data.

Code:
Option Explicit


Sub Normalize()
    Dim s1 As Worksheet, s2 As Worksheet
    Set s1 = Sheets("Sheet1")
    Set s2 = Sheets("Sheet2")
    Dim i As Long, j As Long, lr As Long, lr2 As Long, lc As Long
    lr = Range("A" & Rows.Count).End(xlUp).Row
    s2.Range("A1") = "Organization"
    s2.Range("B1") = "Product"
    For i = 2 To lr
        lr2 = s2.Range("B" & Rows.Count).End(xlUp).Row
        lc = s1.Cells(i, Columns.Count).End(xlToLeft).Column
        s1.Range("A" & i).Copy s2.Range("A" & lr2 + 1)
        s1.Range(Cells(i, 2), Cells(i, lc)).Copy
        s2.Range("B" & lr2 + 1).PasteSpecial xlPasteValues, , , True
        lr2 = s2.Range("B" & Rows.Count).End(xlUp).Row
    Next i
    For i = 3 To lr2
        If s2.Range("A" & i) = "" Then
            s2.Range("A" & i) = s2.Range("A" & i - 1)
        End If
    Next i
End Sub

Pivot would look like this

Data Range
A
B
C
D
E
F
G
H
I
J
K
2
Row Labels​
Beans - CANNED​
Beans - DRY​
Beet - CANNED​
Garlic - SPECIALTY​
Mixed Fruit - FROZEN​
Onions - FROZEN​
Onions - ORGANIC​
Onions - WHOLE PEELED​
Potatoes: Diced - FROZEN​
Potatoes: Russett - FROZEN​
3
Azure Standard​
1​
1​
1​
1​
1​
4
Basic American Foods, Inc.​
1​
1​
2​
5
Beaverton Foods, Inc.​
1​
1​
1​
6
Boardman Foods, Inc.​
1​
1​
7
Calbee North America, LLC​
1​
1​
1​
 
Upvote 0

Forum statistics

Threads
1,215,707
Messages
6,126,353
Members
449,311
Latest member
accessbob

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