I would then need to add logic that would somehow move the spell already in the active box back to the inventory.
But you don't need to move it back, because the spell should not have been removed from the inventory in the first place!
When you assign some scroll/potion to the active slot, the inventory should not change. The item stays where it is. Only the global variable changes, and an image of the scroll appears in the active slot - you can even use a different sprite to make it less confusing.
.
That youtube tutorial you found isn't very good.. Usually an inventory system is based on an array or JSON object. All collected items and their quantities are stored in the array. When "I" is pressed, the inventory screen is dynamically generated from the array data.