+ Reply to Thread
Results 1 to 5 of 5

VBA to find out missing combination

  1. #1
    Registered User
    Join Date
    08-23-2012
    Location
    amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    95

    VBA to find out missing combination

    Hi Guys,

    Once again I would need you help please.

    I really need a VBA code to find and identify missing combination between values organized in two columns A:A & B:B.

    • Column A is populated with a list (very long, about 50K) of part numbers.
    • Column B is populated with 9 location codes: NL10; AU21;CH20;NL20;NO20;NZ20;RO20;SE20;ZA20

    Actually all the part numbers in A:A should be repeated nine times as each of them should be present in all the locations, NL10 is compulsory so is always there.
    The code should check and find out what are the missing locations for each part number.
    I've attached a sample to explain practically what the VBA code should do and how my worksheet is organized.

    PLEASE help
    Attached Files Attached Files

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,873

    Re: VBA to find out missing combination

    How about a Pivot Table. No VBA required.

    Data Range
    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    K
    1
    2
    3
    Count of PLANT
    PLANT
    4
    P/N
    AU21
    CH20
    NL10
    NL20
    NO20
    NZ20
    RO20
    SE20
    ZA20
    Grand Total
    5
    1fff.9011
    1
    1
    6
    1fff.902
    1
    1
    1
    3
    7
    1fff.903
    1
    1
    8
    1fff.904
    1
    1
    9
    1fff.905
    1
    1
    10
    1fff.906
    1
    1
    11
    1fff.907
    1
    1
    12
    1fff.908
    1
    1
    1
    1
    1
    1
    1
    1
    1
    9
    13
    1xxx.000
    1
    1
    1
    1
    1
    1
    1
    1
    1
    9
    14
    1xxx.001
    1
    1
    1
    1
    1
    5
    15
    1yyy.231
    1
    1
    16
    1yyy.232
    1
    1
    17
    1yyy.233
    1
    1
    18
    1yyy.234
    1
    1
    1
    1
    1
    1
    1
    1
    1
    9
    19
    1zzz.000
    1
    1
    2
    20
    Grand Total
    3
    3
    15
    6
    4
    4
    5
    3
    3
    46
    21
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    08-23-2012
    Location
    amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    95

    Re: VBA to find out missing combination

    Hi Alansidman,

    thanks for you help

    not sure I understood you.

    you've built a table using data that you are supposing it is already there...but I don't know which plants are missing, so I cannot build the table...the only initial data that I have is what you see in columns A and B, in the real scenario all the other columns would be empty (I filled them in as an example of what VBA should do)

    How could I fill in the table when you have more than 50k part numbers?
    I agree with you pivot strategy but after I have all the data, but first I have to get it... or Am I wrong and I didn't get your suggestion?

    Thanks!

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,873

    Re: VBA to find out missing combination

    Build a Pivot table. In the example, where there is no number, you are missing the item. If you don't know or understand Pivot tables, then look at these tutorials.

    http://www.datapigtechnologies.com/ExcelMain.htm

    Scroll down to the section on Pivot tables.

    In your example, I only used the columns A & B to generate the Pivot Table, using the Pivot Table Wizard. I did not manually build the table. Excel did it for me using only the data in Columns A & B.
    Last edited by alansidman; 03-19-2016 at 08:11 PM.

  5. #5
    Registered User
    Join Date
    08-23-2012
    Location
    amsterdam
    MS-Off Ver
    Excel 2010
    Posts
    95

    Re: VBA to find out missing combination

    ah Got it! thanks a lot, sorry if I didn't catch on the spot, yes I can use a pivot table and then I can also export data out of the pivot and filter at will.

    Thank you so much mate!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Find missing number and copy only missing number to another coloumn
    By vijaynadiad in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-20-2013, 02:01 PM
  2. Excel Macro to find missing dates and insert missing date as blank row
    By JevaMarie in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-26-2013, 11:08 AM
  3. Find the Combination of different Lenth
    By yasar in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-19-2013, 12:11 PM
  4. A Missing Unique Combination
    By JTM1200 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-25-2012, 11:46 AM
  5. Find an optimal combination
    By Totoleheros in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 10-05-2010, 01:30 AM
  6. find best combination
    By orenw8 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-20-2010, 07:39 PM
  7. Combination of if and find function possible ?
    By wjviveen in forum Excel General
    Replies: 3
    Last Post: 08-29-2007, 10:42 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1