如果僅20行,使用這個方法,比較簡單易懂,不用動腦筋,如下:
使用公式
=A1&IF(COUNTIF($A$1:A2,A2)=1,A2,"")&IF(COUNTIF($A$1:A3,A3)=1,A3,"")&IF(COUNTIF($A$1:A4,A4)=1,A4,"")&IF(COUNTIF($A$1:A5,A5)=1,A5,"")&IF(COUNTIF($A$1:A6,A6)=1,A6,"")&IF(COUNTIF($A$1:A7,A7)=1,A7,"")&IF(COUNTIF($A$1:A8,A8)=1,A8,"")&IF(COUNTIF($A$1:A9,A9)=1,A9,"")&IF(COUNTIF($A$1:A10,A10)=1,A10,"")&IF(COUNTIF($A$1:A11,A11)=1,A11,"")&IF(COUNTIF($A$1:A12,A12)=1,A12,"")&IF(COUNTIF($A$1:A13,A13)=1,A13,"")&IF(COUNTIF($A$1:A14,A14)=1,A14,"")&IF(COUNTIF($A$1:A15,A15)=1,A15,"")&IF(COUNTIF($A$1:A16,A16)=1,A16,"")&IF(COUNTIF($A$1:A17,A17)=1,A17,"")&IF(COUNTIF($A$1:A18,A18)=1,A18,"")&IF(COUNTIF($A$1:A19,A19)=1,A19,"")&IF(COUNTIF($A$1:A20,A20)=1,A20,"")
去重合並
如果是只想在壹個單元格用公式得出結果,Excel 2013以前貌似只能借助VBA自定義函數實現(操作起來倒也簡單,就是文件要保存成xlsm),好用的TEXTJOIN函數是Excel 2016才出現的,有條件升級壹下也可以考慮使用。
如果不升級,不用VBA,可以通過加1個輔助列處理,如數據在A1:A5000,則
B1=A1
B2=IF(COUNTIF($A$1:A2,$A$1:$A$5000)=1,B1&$A$1:$A$5000,B1)
B2公式復制到B5000,這樣就能在B5000得到答案。這個方法不需要考慮A列是什麽數據類型,只要合並起來總字符數不超過32767即可。
這種方法逆序也很容易,就是B1=IF(COUNTIF($A1:$A$5000,$A$1:$A$5000)=1,B2&$A$1:$A$5000,B2)
B1公式復制到B4999,
B5000=A5000
即可在B1得到答案。
正逆序去重合並(輔助列法)
以上希望能幫上忙!