Calc: insert row when cell content changes and add content of the cell to the line

Hello,

I have a rather complicated task, so far I’ve been doing it manually but it’s becoming very repetitive (over 1500 rows).

I have the following table:

category - product - price
drinks     - beer     - 20
drinks     - wine    -  30
drinks     - tea      -  10
food       - rice      -  25
food       - bread   -  35
food       - fruit    -   15

I need the following result:

product       - price
drinks
beer           -  20
wine           -  30
tea            -  10
food
rice           -  25
bread          -  35
fruit          -  15

I.e. when the category changes, an empty row is added above, the name of the category is copied to the new row to the product cell and when it’s done, the category column is deleted.

A friend of mine told me he used to be able to do this using formulas, I’m not sure about that and I think a macro needs to be written for that. What do you think?

Thank you very much

Petr Břeň

Also asked at the OpenOffice forum