The effectiveness of building energy codes is studied taking a long-run perspective. We focus on regulation´s impact on energy demand in high-end and low quality residences, i.e. the diffusion and the entry of "green" buildings in the housing market. We develop a measure for regulation intensity and apply this to a panel-error-correction regression model for energy requirements of a large sample of German apartment houses built between 1950-2005. We show that regulation is effective in saving energy. In particular, regulation pushes investors in the low quality housing market segment towards the technological frontier. Indirectly, it also affects the high-end housing market segment.