A general method is developed to treat density-dependent effective nucleon-nucleon interactions in shell-model calculations. A trial function is introduced, that can generate any excitation mode of the nucleus. The method is based on the evaluation of the expectation value of the full Hamiltonian with respect to this generating Slater determinant wave function. Rearrangement effects, due to the density-dependence of the interaction are systematically included. The proposed formalism is applied in first instance to simplified excitation modes, such as two-quasiparticle and particle-hole configurations. A detailed study on the importance of the various types of rearrngement terms is carried out. A more specific application of the general formalism is presented in carrying out an extended shell-model calculation on 116Sn, including, apart from the neutron 2qp-excitations, proton 1p-1h excitations and coupled excitations of the type (1p-1h) ⊗ (2qp).