The production of (1S), (2S), and (3S) is investigated in pPb and pp collisions at centre-of-mass energies per nucleon pair of 5.02 TeV and 2.76 TeV, respectively. The datasets correspond to integrated luminosities of about 31 nb(-1) (pPb) and 5.4 pb(-1) (pp), collected in 2013 by the CMS experiment at the LHC. Upsilons that decay into muons are reconstructed within the rapidity interval |y (CM)| < 1.93 in the nucleon-nucleon centre-of-mass frame. Their production is studied as a function of two measures of event activity, namely the charged-particle multiplicity measured in the pseudorapidity interval |eta| < 2.4, and the sum of transverse energy deposited at forward pseudorapidity, 4.0 < |eta| < 5.2. The cross sections normalized by their...