Sounds like damaged voltage regulator
When the mega is plugged into the ramps its generates 5v from the 12v fed into the vin pin of the mega. This goes threw a voltage regulator to produce 5v.
Now when you plug in the USB cable the 5v is powered from USB, ignoring the voltage regulator
When the mega is plugged into the ramps its generates 5v from the 12v fed into the vin pin of the mega. This goes threw a voltage regulator to produce 5v.
Now when you plug in the USB cable the 5v is powered from USB, ignoring the voltage regulator