PDA

View Full Version : Need help to combine two tables under certain conditions



mgspk01
05-27-2013, 08:04 AM
Hello.

I'm new to this forum, but hopefully someone will be able to help me with this task, which is very important for my work.

There are 2 tables for different months with the same set of columns and a lot of rows. Number of SYSNAMES for each SYSCODE may vary (SYSNAME may be new or deleted).

I need those tables combined under the following conditions:

a) rows from TAB2 that are not in TAB1 (identifiers would be SYSCODE and SYSNAME) must be added into resulting table and highlighted
b) resulting table must have a %-column from TAB2
c) resulting table must have a new column for a simple math (%TAB1 minus %TAB2)

Basically, it supposed to look like on the picture attached. I tried to apply and customize various solutions I was able to find on the Internet, but with no avail. My level of scripting is not so good.

Can anyone look at this case and help me to automate the process as much as possible? It's just too many rows in those tables to process them manually.

Any help will be much appreciated.

P.S. TAB1 and TAB2 will probably be located on a separate sheets.

mgspk01
05-27-2013, 09:43 AM
Attached workbook.

SamT
05-27-2013, 01:42 PM
I don't have any more time today, but this is one way to do it. Not the best, just easiest to figure out.

Copy Tab1 Columns ("A:C") to results sheet
Append Tab2 Columns ("A:C") to end on Results sheet.
Sort columns and delete duplicates.

For each Row on Results, Concatenate three cells and
For each Row on Tab1, concatenate cells and compare.
If identical copy % to Results Tab1% column
Next
Next

Repeat loops for Tab2 %'s

Apply formula to (Tab1% - Tab2%) column