The array gain of a superdirective antenna array can be proportional to the square of the number of antennas. However, the realization of the so-called superdirectivity entails accurate calculation and application of the excitations. Moreover, the excitations require a large dynamic power range, especially when the antenna spacing is smaller. In this paper, we derive the closed-form solution for the beamforming vector to achieve superdirectivity. We show that the solution only relies on the data of the array electric field, which is available in measurements or simulations. In order to alleviate the high requirement of the power range, we propose a genetic algorithm based approach with a certain excitation range constraint. Full-wave electromagnetic simulations show that compared with the traditional beamforming method, our proposed method achieves greater directivity and narrower beamwidth with the given range constraints.