Offense on the left hash runs a sweep to the right hash. Called for illegal shift. Do we walk off the five from the left hash and snap it from there again?
Enforcement is from the previous SPOT (not yard line), so yes, back to the left hash.
Same play start on left hash and sweep to right hash. There is now holding in the center of the field between hashes. Do we walk off from the flag and snap it from the center?
Enforcement is from the SPOT of the foul, so yes - UNLESS the run ended behind the spot of the foul. Now your enforcement spot becomes the end of the run.
Think about your enforcement SPOT and not a yard line, and you should be fine.
And while I think this should always be right, in the grand scheme of things, getting the wrong hash is a minor ding, not a major one.