Policy makers are often interested in the distributional effects of a policy. In this paper I propose a method to estimate the actual and counterfactual distributions of an outcome variable when the treatment variable is endogenous, continuous, and its effect is heterogeneous. The model is a triangular system of equations in which the unobservables are related by a copula that captures the endogeneity of the treatment, which is nonparametrically identified by inverting the quantile processes that determine the outcome and the treatment. Both processes are estimated using existing quantile regression methods, and I propose a parametric and a nonparametric estimator of the copula. I conduct three kinds of counterfactual experiments: changing the distribution of the treatment, changing the distribution of the instrument, and changing the rule that determines the treatment, and I discuss the estimation of each of these counterfactuals. To illustrate these methods, I estimate several counterfactuals that affect the distribution of the share of food consumption.