Experts!
I'm still struggling with what types of macro to use.
I have two table I need to join. One table contains mapping logic while another table contains transactions.
Logic table
| Logic ID | Region | City | Factory | Product Category | Mapping Column01 | Mapping Column02 | Mapping Column03 | Mapping Column04 |
| 1 | West | San Francisco | A | * | Region | City | Factory | |
| 2 | West | Irvine | * | * | Region | City | | |
| 3 | West | Los Angeles | A | X | Region | City | Factory | Product Category |
| 4 | East | New York | A | * | Region | City | Factory | |
| 5 | Central | * | * | * | Region | | | |
| 6 | West | * | * | * | Region | | | |
| 7 | East | * | A | * | Region | Factory | | |
| 8 | East | * | * | * | Region | | | |
Transaction Table
| Transaction ID | Region | City | Factory | Product Category | Amount | |
| 1 | West | Los Angeles | A | X | 100 | ==> should be mapped with Logic 3 and 6 |
| 2 | West | Oakland | B | Y | 200 | ==> should be mapped with Logic 6 |
| 3 | East | New York | A | X | 300 | ==> should be mapped with Logic 4 ,7 and 8 |
| 4 | Central | Chicago | A | X | 400 | ==> should be mapped with Logic 5 |
| 5 | East | Boston | A | X | 500 | ==> should be mapped with Logic 7 and 8 |
| 6 | West | San Francisco | A | X | 600 | ==> should be mapped with Logic 1 and 6 |
I've tried "Transpose" and "Crosstab" method and kinda figured it out.
But, I would like to know whether it can be done using a macro.
Do you have a good idea for this?
I'd really appreciate you experts' help and advice.
Ideal method that I would love to try is feeding those mapping columns into a macro so the macro knows which columns to use for joining.
Is this doable using a macro?
----------------
Thank you all for the responses. It has been a great help.
Regarding the issue that I am facing with the solution below;
| Logic ID | Region | City | Factory | Product Category |
| 1 | West | Irvine | * | X |
If I have transactions as below
| Transaction ID | Region | City | Factory | Product Category | Amount |
| 1 | West | Irvine | A | X | 100 |
| 2 | West | Irvine | B | X | 200 |
The second transaction wouldn't be mapped with the logic since the cross tab will only pick up the Factory 'A' due to the "FIRST" setting in the crosstab.
Thank you so much for your help!!!!