Hi all
Tried to solve this problem using formulas which was manageable, but only by adding several helper columns and having a formula too complex for "normal" users to read and understand.
So now I try to have it done with VBA instead.
In short the task is to find pairs of "siblings" with the same parent. See enclosed workbook for illustration.
Outcome
Range with comments in sheet 1, column D
Information
Sheet 1 is the main sheet. This is where the matching should be done
Sheet 2 contains all siblings. This sheet is used for identifying siblings
Criteria
- Column A in sheet 1 should contain more than one entry of the Top Item ID. E.g. 6083966 has 9 entries. If only one entry the function should return a comment e.g. "6083977 only one entry". (Highlighted in blue)
- If more than one entry in column A sheet 1, next step is to check if the Item ID in column B. If the Item ID has duplicates in either column A or B in sheet 2, the function should return a comment "Multiple entries in Sheet 2" (Highlighted in orange)
- If there is only one entry in either column A or B in sheet 2, the function should match the related sibling. E.g. Item ID 6023864 has a sibling in sheet 2, 6179298. This goes both ways so that for Item ID 6179298 the function should return sibling 6023864 (Highlighted in Yellow)
- A pair of siblings should always have the same parent. E.g siblings 6023864 & 6179298 has the parent 6083966 = OK. But there is also a pair of siblings with different parents = Not OK (highlighted in red)
- If a pair of siblings have the same parent last step is to check if the pair of siblings have both texts "Only Eng" & "Only Supp". If not = Not OK (highlighted in grey)
- Examples of successful matches are highlighted in green.
My biggest problem so far with this problem is speed and ensuring all criteria is met. Main sheet 1 can contain anywhere from 2000 rows up to 20000 rows to be checked. Sheet 2 contains anywhere from 2000 rows up to 6000 rows.
I am thinking populating the ranges in arrays and doing the comparing there would be the fastest approach.
Looking forward to hearing from you.
Bookmarks