If you use the Table Feature in Excel, you r requirement will automatically be fulfilled.

Have you tried it?

Deep