MrSamExcel
Board Regular
- Joined
- Apr 6, 2016
- Messages
- 50
- Office Version
- 365
- 2021
- Platform
- Windows
Excel 2013 64 bit
[TABLE="class: head"]
<tbody>[TR="bgcolor: #888888"]
[TH][/TH]
[TH]
[TH]
[TH]
[TH]
[TH]
[TH]
[TH]
[TH]
[TH]
[TH]
[TH]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
[TD]ID[/TD]
[TD]
[TD]
[TD]
[TD]
[TD]
[TD]
[TD]
[TD]
[TD="bgcolor: #5B9BD5"]Note Formula[/TD]
[TD="bgcolor: #70AD47"]Script Formula[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
[TD]ABC[/TD]
[TD][/TD]
[TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="bgcolor: #5B9BD5"]FT014[/TD]
[TD="bgcolor: #70AD47"]1[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
[TD]DEF[/TD]
[TD][/TD]
[TD]
[TD]
[TD][/TD]
[TD]
[TD]
[TD]
[TD]
[TD="bgcolor: #5B9BD5"]FT014, FT015, FT016[/TD]
[TD="bgcolor: #70AD47"]1, 2, 3[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
[TD]ZYX[/TD]
[TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]
[TD]
[TD]
[TD]
[TD="bgcolor: #5B9BD5"]FT014, FT016[/TD]
[TD="bgcolor: #70AD47"]1, 2[/TD]
[/TR]
</tbody>[/TABLE]
In the example above, is there a formula I could place in J2:J4 and K2:K4 to produce the results I've typed manually?
1. Note Formula returns all distinct non-blank values in the range, each separated by a comma and a space
2. Script Formula produces sequence from 1 to n, where n is the number of distinct non-blank values in the range, each separated by a comma and a space
I can get the n using =SUMPRODUCT((B2:I2<>"")/COUNTIF(B2:I2,B2:I2&""))
I could then create nested IF statements -- IF(n=1, "1", IF(n=2, "1, 2", IF(etc.))) -- but is there a more elegant approach I could learn?
[TABLE="class: head"]
<tbody>[TR="bgcolor: #888888"]
[TH][/TH]
[TH]
A
[/TH][TH]
B
[/TH][TH]
C
[/TH][TH]
D
[/TH][TH]
E
[/TH][TH]
F
[/TH][TH]
G
[/TH][TH]
H
[/TH][TH]
I
[/TH][TH]
J
[/TH][TH]
K
[/TH][/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
1
[/TD][TD]ID[/TD]
[TD]
FCM
[/TD][TD]
FP
[/TD][TD]
FCLMS
[/TD][TD]
SD
[/TD][TD]
AED
[/TD][TD]
LAD
[/TD][TD]
WAEM
[/TD][TD]
ABP
[/TD][TD="bgcolor: #5B9BD5"]Note Formula[/TD]
[TD="bgcolor: #70AD47"]Script Formula[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
2
[/TD][TD]ABC[/TD]
[TD][/TD]
[TD]
FT014
[/TD][TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD="bgcolor: #5B9BD5"]FT014[/TD]
[TD="bgcolor: #70AD47"]1[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
3
[/TD][TD]DEF[/TD]
[TD][/TD]
[TD]
FT014
[/TD][TD]
FT015
[/TD][TD][/TD]
[TD]
FT016
[/TD][TD]
FT016
[/TD][TD]
FT016
[/TD][TD]
FT016
[/TD][TD="bgcolor: #5B9BD5"]FT014, FT015, FT016[/TD]
[TD="bgcolor: #70AD47"]1, 2, 3[/TD]
[/TR]
[TR="bgcolor: #FFFFFF"]
[TD="bgcolor: #888888"]
4
[/TD][TD]ZYX[/TD]
[TD]
FT028
[/TD][TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]
FT016
[/TD][TD]
FT016
[/TD][TD]
FT016
[/TD][TD]
FT016
[/TD][TD="bgcolor: #5B9BD5"]FT014, FT016[/TD]
[TD="bgcolor: #70AD47"]1, 2[/TD]
[/TR]
</tbody>[/TABLE]
In the example above, is there a formula I could place in J2:J4 and K2:K4 to produce the results I've typed manually?
1. Note Formula returns all distinct non-blank values in the range, each separated by a comma and a space
2. Script Formula produces sequence from 1 to n, where n is the number of distinct non-blank values in the range, each separated by a comma and a space
I can get the n using =SUMPRODUCT((B2:I2<>"")/COUNTIF(B2:I2,B2:I2&""))
I could then create nested IF statements -- IF(n=1, "1", IF(n=2, "1, 2", IF(etc.))) -- but is there a more elegant approach I could learn?
Last edited: