Been there.... done that. We call it "The joys of growing".
I always use clones these days for just that exact reason. When I buy seeds, I grow them normally, put them in veg and wait for them to show their sex, them put them back into flower and clip them for clones after they've switched back...