keda duck
Board Regular
- Joined
- Jul 9, 2023
- Messages
- 54
- Office Version
- 365
- 2021
- 2019
- 2016
- 2013
- 2011
- 2010
- 2007
- Platform
- Windows
1. Column A data is an indefinite length text (within 100 characters) composed of any natural number, ensuring that any number in the text is greater than the preceding number;
2. Compress consecutive numbers, such as 1, 2, 3, 4 in A2, which are consecutive numbers and compressed into 1-4, 11, 12 in A2, which are consecutive numbers and compressed into 11-12, and so on. The final result is shown in B2;
3. If there are consecutive odd or even numbers, they should also be compressed, with consecutive odd numbers marked as single and consecutive even numbers marked as double
Note: Consider 3 first and then consider 2, as shown in rows 6-7
PS:This question came to me based on the schedule of a certain university. I saw several pieces of information in one cell of the schedule: course/week/location/teacher/composition of teaching class/number of course takers, and there may be multiple courses.
The format of the week is very similar to this data source. One cell is written as (3-4 sections) 2-8 weeks, 12-14 weeks (double), 15-17 weeks, and the label "single double" after it refers to attending classes in a single or double week.
When I saw this schedule, I thought it was similar to the problems I had done before, but with some differences. Therefore, I will simplify it and show it to everyone. I hope to use functions to solve it.
2. Compress consecutive numbers, such as 1, 2, 3, 4 in A2, which are consecutive numbers and compressed into 1-4, 11, 12 in A2, which are consecutive numbers and compressed into 11-12, and so on. The final result is shown in B2;
3. If there are consecutive odd or even numbers, they should also be compressed, with consecutive odd numbers marked as single and consecutive even numbers marked as double
Note: Consider 3 first and then consider 2, as shown in rows 6-7
text.xlsx | ||||
---|---|---|---|---|
A | B | |||
1 | source | result | ||
2 | 1,2,3,4,8,11,12,16,17,18 | 1-4,8,11-12,16-18 | ||
3 | 3,5,6,7,9,12,13,14,15,20,101 | 3,5-7,9,12-15,20,101 | ||
4 | 1,3,5,7,9,11 | 1-11(single) | ||
5 | 1 | 1 | ||
6 | 2,4,6,8,10,12,14,16,17 | 2-16(double),17 | ||
7 | 1,5,6,7,9,12,13,14,15,16 | 1,5-6,7-9(single),12-16 | ||
8 | 2,3,4,5,6,7,10,17,22,23,24,25,26,77 | 2-7,10,17,22-26,77 | ||
9 | 3,4,7,13,15,16,17 | 3-4,7,13-15(single),16-17 | ||
10 | 1,2,3,4,5,6,7,13,15,17 | 1-7,13-17(single) | ||
11 | 3,5,7,13,22,24,26,28,30,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80 | 3-7(single),13,22-80(double) | ||
12 | 2,3,4,7,12,14,17,18 | 2-4,7,12-14(double),17-18 | ||
Sheet9 |
PS:This question came to me based on the schedule of a certain university. I saw several pieces of information in one cell of the schedule: course/week/location/teacher/composition of teaching class/number of course takers, and there may be multiple courses.
The format of the week is very similar to this data source. One cell is written as (3-4 sections) 2-8 weeks, 12-14 weeks (double), 15-17 weeks, and the label "single double" after it refers to attending classes in a single or double week.
When I saw this schedule, I thought it was similar to the problems I had done before, but with some differences. Therefore, I will simplify it and show it to everyone. I hope to use functions to solve it.