คุณสามารถใช้IF
ฟังก์ชั่นดังนี้:
=IF(P2<>"",P2&", ","") & IF(Q2<>"",Q2&", ","") & IF(R2<>"",R2&", ","") & IF(AD2<>"",AD2&", ","") & IF(AE2<>"",AE2&", ","") & IF(AF2<>"",AF2,"")
สิ่งนี้มีความเป็นไปได้ที่จะมีเครื่องหมายจุลภาคพิเศษในตอนท้ายซึ่งคุณสามารถลบได้โดยใช้สิ่งต่อไปนี้:
=IF(RIGHT(string,1)=",",LEFT(string,LEN(string)-1),string)
โดยที่string
เอาต์พุตของสูตรก่อนหน้า (หรือสตริงอื่น ๆ )
สะสมเป็นสูตรน่าเกลียดหนึ่งมันจะมีลักษณะเช่นนี้:
=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,""))