# Cleaning up messy data from PDF report, need to match up purchase order numbers with supplier names on 2 separate rows

#### Tosborn

##### New Member
The messy data looks like the list in columns A & B (see image), the finished list needs to be like columns D&E. I'm cleaning up some very messy data with formulas on the spreadsheet up to this point but the solution could be with VBA also, I'm open to either.

So basically the purchase order number relates to the supplier below and the reverse is true also, the supplier name relates to the purchase order above.

The kicker is the supplier names repeated multiple times along the spreadsheet all the way down but always relate to the purchase order immediately in a non blank row above. That is, a supplier relates to multiple purchase orders but each purchase order only relates to one supplier.

Purchase order numbers are not repeated.

There is no mathematical consistency to the blank rows between PO & supplier.

#### Attachments

• purchase orders.PNG
23.6 KB · Views: 15

### Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Hi Tosborn,

To simplify the formulae somewhat I've added a PO Row column.

Tosborn.xlsx
ABCDEFGH
1Messy data:Desired finished list:
2Purchase OrderSupplierPO RowPurchase OrderSupplier
318760-00118760-00Supplier 9
4618869-00Supplier 6
51018877-00Supplier 7
6Supplier 9
7
818869-00
9Supplier 6
10
11Supplier 6
1218877-00
13
14
15Supplier 7
Sheet1
Cell Formulas
RangeFormula
F3:F12F3=IFERROR(AGGREGATE(15,6,ROW(\$A\$3:\$A\$999)-ROW(\$A\$2)/(\$A\$3:\$A\$999<>""),ROW()-ROW(\$F\$2)),"")
G3:G12G3=IF(F3="","",INDEX(\$A\$3:\$A\$999,F3))
H3:H12H3=IFERROR(INDEX(\$B\$3:\$B\$999,AGGREGATE(15,6,ROW(\$B\$3:\$B\$999)-ROW(\$B\$2)/((\$B\$3:\$B\$999<>"")*(ROW(\$B\$3:\$B\$999)>F3-ROW(\$B\$2))),ROW()-ROW(\$F\$2))),"")

Replies
1
Views
290
Replies
10
Views
441
Replies
0
Views
420
Replies
0
Views
770
Replies
0
Views
268

1,212,134
Messages
6,106,147
Members
447,998
Latest member
tippairie1

### 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.

### Which adblocker are you using?

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

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