You could use IF
functions as follows:
=IF(P2<>"",P2&", ","") & IF(Q2<>"",Q2&", ","") & IF(R2<>"",R2&", ","") & IF(AD2<>"",AD2&", ","") & IF(AE2<>"",AE2&", ","") & IF(AF2<>"",AF2,"")
This has a possibility of having an extra comma at the end, which you can remove using the following:
=IF(RIGHT(string,1)=",",LEFT(string,LEN(string)-1),string)
where string
is the output of the previous formula (or any other string).
Rolled up into one ugly formula, it would look like this:
=IF(RIGHT(IF(P2<>"",P2&", ","") & IF(Q2<>"",Q2&", ","") & IF(R2<>"",R2&", ","") & IF(AD2<>"",AD2&", ","") & IF(AE2<>"",AE2&", ","") & IF(AF2<>"",AF2,""),1)=",",LEFT(IF(P2<>"",P2&", ","") & IF(Q2<>"",Q2&", ","") & IF(R2<>"",R2&", ","") & IF(AD2<>"",AD2&", ","") & IF(AE2<>"",AE2&", ","") & IF(AF2<>"",AF2,""),LEN(IF(P2<>"",P2&", ","") & IF(Q2<>"",Q2&", ","") & IF(R2<>"",R2&", ","") & IF(AD2<>"",AD2&", ","") & IF(AE2<>"",AE2&", ","") & IF(AF2<>"",AF2,""))-1),IF(P2<>"",P2&", ","") & IF(Q2<>"",Q2&", ","") & IF(R2<>"",R2&", ","") & IF(AD2<>"",AD2&", ","") & IF(AE2<>"",AE2&", ","") & IF(AF2<>"",AF2,""))
put spaces properly to make the formular readable – phuclv – 2016-07-27T03:28:52.637