Necessary and sufficient conditions for a differential system of equations to admit a variational formulation are established by having recourse to Vainberg's theorem which provides also a systematic method for producing the sought functional. An application of the method to the Lagrangian description of fluid dynamics leads to a new variational principle which, while being fully general, reveals a hierarchy between variational approaches to fluid dynamics. Next, the method is applied in an attempt to obtain new variational formulations in various areas of research pertaining to continuum physics: water wave models, elasticity, heat conduction in solids, dynamics of anharmonic crystals, and electromagnetism. Owing to the power of the method, relevant variational formulations are found whenever the given system allows them. The paper places particular emphasis on equations which have, or are supposed to have, soliton solutions.