I need to to stack multiple columns into one using an if statement as the example below
Original table looks like the following:
Type | ID | Name | State | X | Y |
---|---|---|---|---|---|
Pay | 01 | Joe | NY | -5 | 0 |
Pay | 02 | Ann | FL | -2 | -4 |
Receive | 03 | Lee | TX | 1 | 0 |
Pay | 04 | Ken | CA | 0 | -1 |
Receive | 05 | John | NY | 3 | 2 |
I would like to have the columns Type, ID, X and Y to be copied from sheet1 to sheet2 using the following conditions:
- if Type = "Pay" and X <> 0 then copy columns "Type", "ID" and X * (-1)
- if Type = "Pay" and Y <> 0 then copy columns "Type", "ID" and Y * (-1)
- if Type = "Receive" and X <> 0 then copy columns "Type", "ID" and X
- if Type = "Receive" and Y <> 0 then copy columns "Type", "ID" and Y
I would Like the final result to look like the following:
Type | ID | # | |
---|---|---|---|
Pay | 01 | 5 | X |
Pay | 02 | 2 | X |
Receive | 03 | 1 | X |
Receive | 05 | 3 | X |
Pay | 02 | 4 | Y |
Pay | 04 | 1 | Y |
Receive | 05 | 2 | Y |
Please help me
Thanks Phil