The production of $ Y $ (1S), $ Y $ (2S), and $ Y $ (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 |η| < 2.4, and the sum of transverse energy deposited at forward pseudorapidity, 4.0 < |η| < 5.2. The $ Y $ cross sections normalized by their event activity integrated values, $ Y $ (nS)/〈 $ Y $ (nS)〉, are found to rise with both measures of the event activity in pp and pPb. In both collision systems, the ratios of the excited to the ground state cross sections, $ Y $ (nS)/ $ Y $ (1S), are found to decrease with the charged-particle multiplicity, while as a function of the transverse energy the variation is less pronounced. The event activity integrated double ratios, [ $ Y $ (nS)/ $ Y $ (1S)]pPb /[ $ Y $ (nS)/ $ Y $ (1S)]pp, are also measured and found to be 0.83 ± 0.05 (stat.) ± 0.05 (syst.) and 0.71 ± 0.08 (stat.) ± 0.09 (syst.) for $ Y $ (2S) and $ Y $ (3S), respectively.