A method for optimizing the variety of a modular products, manufactured in a Reconfigurable Manufacturing System, is proposed. The optimization is achieved through appropriately selecting the subsets of module instances from given sets. The problem is formulated as an integer nonlinear programming problem to find a trade-off between the quality loss due to modularity and the cost of reconfiguration for given sets of customer requirements. The proposed formulation is general in the sense that products can have any number of modules. The formulation is an extension to the available formulation that was developed for products with only two modules. Moreover, the current work addresses the effect of different order priorities, customer importance, and demands. The proposed method has been applied to a modular assembly problem and found to be efficient in determining optimum subsets of module instances.