If you really have postcodes along a .csv spreadsheet row, and the codes along another row, then you can do the following:
Now you have all basic unique codes on the first row of the cell D.
the second and consecutive elements in each line (row) of D are all post codes with same basic code.
Further processing could be:
If you find this answer of any help solving your question,
please click on the thumbs-up vote link,
thanks in advance