Problem description & analysis:
In the Excel table below, column A and column B form the content structure. The dates in column A are not arranged in chronological order.
A | B | |
1 | Date | Book Title |
2 | 01.01.2022 | |
3 | Title1 | |
4 | Title2 | |
5 | 03.01.2022 | |
6 | 02.01.2022 | |
7 | Title3 | |
8 | 02.01.2022 | |
9 | Title4 |
Task: Sort dates in column A in correct chronological order while keeping the empty cells in their original positions. Column B will remain what it is.
D | E | |
1 | Date | Book Title |
2 | 01.01.2022 | |
3 | Title1 | |
4 | Title2 | |
5 | 02.01.2022 | |
6 | 02.01.2022 | |
7 | Title3 | |
8 | 03.01.2022 | |
9 | Title4 |
Solution:
Use SPL XLL to do this task:
=spl("=d=E@1(?), d(p=d.pselect@a(~))=d(p).sort(),d",A2:A9)
As shown in the picture below:
Explanation:
E@1 converts a data range to a single-layer sequence. pselect@a gets positions of all members meeting the specified condition; ~ is the current member. "sequence 1(a set of positions)= sequence 2" modifies members of sequence 1 at specified positions into sequence 2.
Please feel free to download esProc Desktop and learn more about how to efficiently manage and clean your Excel data⬇️
SPL download address: esProc Desktop Download
Plugin Installation Method: SPL XLL Installation and Configuration
References to other rich Excel operation cases: Desktop and Excel Data Processing Cases
SPL Programming (YouTube FREE courses): https://www.youtube.com/playlist?list=PLQeR-IhHo7qNCw6o7PW8YfHvRx8pgzZso