Not an easy one:

I have a dataset which I need to reorder through a macro.

----------------------------------------------
A ......B ......C ...... D ......E ...... ...... ...... ---> main spreadsheet columns

a b c ...... ...... ...... ...... ...... ...... ...... .. ---> data set (each letter represents a cell with a given value)

c e ...... ...... ...... ...... ...... ...... ...... .....---> data set

f ...... ...... ...... ...... ...... ...... ...... ...... .---> data set
----------------------------------------------

I want the macro to position the data set according to the main columns' value, the sorting rule should be:

if the cell value = main column value, then position that cell under that column. Otherwise leave it where it is.

the intial example should become in this case:
----------------------------------------------
A ......B ......C ...... D ......E ...... ...... ....---> main columns

a ..... b ......c ...... ...... ...... ...... ...... . ---> each cell has been repositioned under the corresponding column

..................c................ e ...... ...... ....---> each cell has been repositioned under the corresponding column
f ...... ...... ...... ...... ...... ...... ...... ......---> this cell had no corresponding column, so it has been left where it was!
----------------------------------------------
any suggestions please?