Hello everyone. This is my first post.
In an application I use for work I have a list of 41 items that have to be sorted in a specific order.
Unfortunately the only way to order it, it is to move each item up and down until it reaches the desired position (and of course doing this changes the position of other items)
Now, as this is a tedious job I need to do over 500 times, I wanted to see if there is a quick way to find using VBA the lowest number of moves to have them all sorted correctly.
Let me be more clear with an example with just 4 items.
I have 4 colours that have to sorted as:
1. Yellow
2. Blue
3. Green
4. Red
Given an initial order:
1. Yellow
2. Red
3. Green
4. Blue
The quickest way is:
Move Red down by 2 positions
Move Green down by 1 position.
I know that it can also be like
move Blue up by 2 positions
Move red down by 1 position.
I actually do not care, as long as I get the lowest number of moves.
Is there a way I can get a VBA showing me the shortest possible list of moves I have to do to sort the full list the way I want?
Thank you in advance to anyone that can help me.
Bookmarks