In this paper, we present an automatic and flexible approach for software component substitution. When a component is removed from an assembly, most existing approaches perform component-to-component substitution, relying on the fact that such a candidate component is available, which is hardly to happen because the constraints on its interfaces are too strong. When such a component does not exist, it would be more flexible to allow a single component to be replaced by a whole component assembly. We propose such an automatic substitution mechanism which does not need the changes to be anticipated and preserves the quality of the assembly.