In an Excel table, find rows corresponding to the 1st and the last non-empty cells in each column
In the Excel table below, columns from the 2nd to the 6th has empty cells.
A | B | C | D | E | F | |
1 | StartDate | QID1 | QID2 | QID3 | QID4 | QID5 |
2 | 10/03/2024 10:56 | 1 | yes | 3 | 2 | |
3 | 10/03/2024 03:10 | 2 | no | 4 | 23 | |
4 | 09/03/2024 19:25 | 3 | yes | 2 | 2 | |
5 | 09/03/2024 11:40 | 4 | no | 1 | yes | |
6 | 09/03/2024 03:55 | 5 | yes | 5 | no | |
7 | 08/03/2024 20:10 | 6 | ||||
8 | 08/03/2024 12:25 | 7 | no | |||
9 | 08/03/2024 04:40 | 8 | yes | |||
10 | 07/03/2024 20:55 | 9 | no | |||
11 | 07/03/2024 13:10 | 1 | no | no | ||
12 | 07/03/2024 05:25 | 2 | no | no | ||
13 | 06/03/2024 21:40 | 3 | no | no | ||
14 | 06/03/2024 13:55 | 4 | no | |||
15 | 06/03/2024 06:10 | 5 | no | 3 |
Task: From each column from the 2nd to the 6th, find the first and the last non-empty cells and concatenate the cell values they correspond in the 1st column using "to".
H | I | |
1 | QID1 | 06/03/2024 06:10 to 10/03/2024 10:56 |
2 | QID2 | 06/03/2024 06:10 to 10/03/2024 10:56 |
3 | QID3 | 09/03/2024 03:55 to 10/03/2024 10:56 |
4 | QID4 | 06/03/2024 06:10 to 07/03/2024 13:10 |
5 | QID5 | 09/03/2024 03:55 to 10/03/2024 10:56 |
Use SPL XLL to do this:
=spl("=d=E@2p(?),d.to(2,).(d(1)(~.pselect@z(~)) /""to""/ d(1)(~.pselect(~)))",A2:F15)
E@2p converts a two-layer sequence to a table sequence. pselect()function gets position of the first member that meets the specified condition; @z enables a search backwards. to(2,) gets members from the 2nd to the last; (1) represent the 1st member.
SPL Official Website 👉 https://www.esproc.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProc_Desktop/
SPL Learning Material 👉 https://c.esproc.com
Discord 👉 https://discord.gg/sxd59A8F2W
Youtube 👉 https://www.youtube.com/@esProcDesktop
Linkedin Group 👉 https://www.linkedin.com/groups/14419406/