Question:
Problem: The details of item can’t move together when latest stock update.The picture below shows the initial input:

The picture below shows the problem when the stock changes:

Desired Output:

The formula of Name column for repeat the item:
Answer:
Suggestion
Using apps script
Not sure if it is possible using formula, but here’s a script you can use. This of course still needs some tweaking to align with your spreadsheet.
Also what I’ve done with the script is it deletes both the last name and detail if you change it to lower stock since it makes more sense rather than keeping it in same spot.
try:

Let me know if this works or if you have other questions.
EDIT – Modified code
If you have better answer, please add a comment about this, thank you!