You can model this situation with an equivalent circuit diagram.
R and r both have a capacity relative to ground and they also have a capacity relative to each other. C
Rr is variable and depends on the distance of the two spheres to each other. So first you bring R and r very close, which makes C
Rr large. Then you ground R (i.e. you close the switch) for a moment which gives C
Rr about the same amount of charge as C
r assuming that C
Rr is much larger than the capacity of the two spheres. After you open the switch again you move the two spheres apart i.e. make C
Rr small. As a result all of the charge from C
Rr is dumped into R which will then have about the same amount of charge as r but with opposite polarity. Of course if C
Rr is not that large because the two spheres are not close enough then R will and up with less charge than r.
Btw. The voltage that drops over C
R while it is still uncharged i.e. before you close the switch, will get closer and closer to the voltage of C
r as the two spheres approach each other but will not exceed it. Only after you ground R and then remove it from r can it's voltage become higher than that of r and that only if R is smaller than r.