I develop new Excel VBA code with macro recorder. It always requires modification but it provides a starting point.

Attach a sample workbook with your data.