'How do I make libreoffice calc update the referenced content from dropdown menus automatically?

I assume this is only possible with macros, so any help with this would be appreciated because I never wrote a macro.

Here's an explanation of what I'm trying to do: Let's say I have a table named categories with 2 entries:

  1. fruits
  2. vegetables

In a second table I have a list of things with a dropdown menu next to them that uses the first table as a source for the selections, so it's easy pick their category:

  1. apples -> fruits
  2. oranges -> fruits
  3. carrots -> vegetables

If I change any field in my categories table (let's say I rename 'fruits' to 'sweet fruits'), the contents selected using the dropdowns won't update (it will still remain 'fruits') because after you select an element in a dropdown menu it uses the text value itself instead of a reference to a field in categories table, so I'm trying to figure out a way to change this to use references somehow, or update every dropdown when I change a category.

Could someone please help me write a macro for doing this? What are your recommendations?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source