When is it worth rebuilding a frame?
Unless the frame is unusually valuable, it is almost never "worth it" to buy new major parts, such as a new rear wheel (with cluster, et al).

A new rear wheel, once you've got the sprockets and tire on it, will cost in excess of $100, and could run $200-300 if you're determined to find "equivalent" parts.  Likewise for a bike missing a fork, a crank assembly, etc.

You can, however, get a pretty good deal using salvaged parts, either salvaging them yourself (from other scrapped bikes) or buying them from bike shops that are into this sort of thing.

I spent this afternoon helping to turn 4 broken bikes into 2 good ones, for the local school system.