Removing blank entries and moving to the left

Maciej1986

New Member
Joined
Feb 2, 2017
Messages
3
Hello everyone,

I have a table of customers who purchased different quantities of different products. Some of them didn't purchase anything. I need to use a non-destructive & updatable way (delete and shift empty cells is a no-no so I think formula or a macro) to assign products and their quantities to customers in a single row, without empty cells and aligned to left. This data will be then fetched by mailmerge in Word document so i need each customer to stay as one record.
Ideally the new table will be to the right of the old one & they will stay in sync.
Have a look below:

excel-query2.jpg


Anyone has any suggestions?
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
May need adjusting according to where your source / target tables reside but something like this:


Book1
ABCDEFGHIJKLMNO
1Product 1Product 2Product 3Product 4Product 5Product 6Product 7
2Customer 152
3Customer 23
4Customer 3
5Customer 41
6Customer 561
7
8Customer 1Product 35Product 62
9Customer 2Product 13
10Customer 3
11Customer 4Product 51
12Customer 5Product 26Product 31
Sheet1
Cell Formulas
RangeFormula
B8{=IFERROR(INDEX($B$1:$H$1,SMALL(IF($B2:$H2>0,COLUMN($B2:$H2)-1),COLUMN()/2)),"")}
C8{=IFERROR(INDEX($B2:$H2,SMALL(IF($B2:$H2>0,COLUMN($B2:$H2)-1),(COLUMN()-1)/2)),"")}
Press CTRL+SHIFT+ENTER to enter array formulas.


Copy the formulas in B8/C8 across and down.

WBD
 
Upvote 0
Try……….

1] Using wideboydixon's table layout in post #2

2] In B8, formula copy across to E8 and all copy down :

=IFERROR(INDEX(($B$1:$H$1,$B2:$H2),0,AGGREGATE(15,6,(COLUMN($B2:$H2)-1)/($B2:$H2>0),INT((COLUMN(A1)-1)/2)+1),MOD(COLUMN(A1)+1,2)+1),"")

Regards
 
Upvote 0
Try……….

1] Using wideboydixon's table layout in post #2

2] In B8, formula copy across to E8 and all copy down :

=IFERROR(INDEX(($B$1:$H$1,$B2:$H2),0,AGGREGATE(15,6,(COLUMN($B2:$H2)-1)/($B2:$H2>0),INT((COLUMN(A1)-1)/2)+1),MOD(COLUMN(A1)+1,2)+1),"")

Regards

One more question - when I insert a new column (lets say before A) - everything is messed up. I tried moving your reference fields around but I cant find logic behind that. Could you explain what should I alter if I wish to insert N new columns on the left of your table?
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,332
Members
449,077
Latest member
jmsotelo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top