In this work the effect of volume exclusion on ionic partitioning in swollen and moderately collapsed gels has been studied through coarse-grained simulations. Our results show that finite size effects yield deviations from the classical theory of Donnan exclusion. At low or moderate reservoir electrolyte concentration these discrepancies become important if one of the ions has diameters of just a few nanometers. When the reservoir electrolyte concentration grows, volume exclusion can lead to a drastic failure of the ideal Donnan exclusion even for conventional hydrated monoatomic ions. In addition, an approximate analytical expression for the partition coefficient of ionic species including the volume exclusion associated with the polymer network and the neutralizing counterions has been proposed and tested. This theoretical approach also provides an expression for the Donnan potential difference that takes such effects into account. Good agreement between theory and simulations is found for slightly and moderately charged gels (both at low and high reservoir electrolyte concentrations). The theory also works acceptably for highly charged gels at high salt concentrations or for electrolytes with large counterions.