I'm sorry, but the requirements you have stated in your post cannot be achieved using built-in Excel formulas or functions. Your requirement is dynamic, and therefore, using VBA is the only solution that comes to my mind. If you are not familiar with VBA, you can read this introductory article...