This document presents a novel approach called LV4MV that determines optimal voltage ranges at the medium voltage (MV) and low voltage (LV) levels of distribution grids. LV4MV sets admissible MV voltage ranges based on the available flexibility from distributed energy resources (DER) connected downstream at the LV level. The goal is to minimize network losses while satisfying grid codes by allowing larger MV voltage ranges where possible through controlled DER response. Test results on real MV and LV networks show how MV ranges can be increased by activating DER flexibility in steps as needed to ensure compliance of LV voltage profiles.