In models with heterogeneous firms trade integration has a positive impact on aggregate productivity through the selection of the best firms as import competition drives the least productive ones out of the market. To quantify the impact of firm selection on productivity, we calibrate and simulate a multi-country multi-sector model with monopolistic competition and variable markups using firm-level data and aggregate trade figures on a panel of 11 EU countries. We find that EU trade has a sizeable impact on aggregate productivity. In 2000 the introduction of prohibitive trade barriers would have caused an average productivity loss of roughly 13 per cent, whereas a reduction of intra-EU trade costs by 5 per cent would have generated a productivity gain of roughly 2 per cent. Productivity losses and gains, however, vary a lot across countries and sectors depending on market accessibility and trade costs. We provide evidence that our results are robust to alternative distance and productivity measures.