We describe a method for computing near-exact energies for correlated systems with large Hilbert spaces. The method efficiently identifies the most important basis states (Slater determinants) and performs a variational calculation in the subspace spanned by these determinants. A semistochastic approach is then used to add a perturbative correction to the variational energy to compute the total energy. The size of the variational space is progressively increased until the total energy converges to within the desired tolerance. We demonstrate the power of the method by computing a near-exact potential energy curve (PEC) for a very challenging molecule -- the chromium dimer.