excel表格同一單元格里剔除重復(fù)詞怎么做?

1. 首先調(diào)出"開(kāi)發(fā)工具"這個(gè)菜單. 在選項(xiàng)里面.

<noscript>
image

</noscript>

image

2. 點(diǎn)開(kāi)VBA, 進(jìn)入VBA界面

<noscript>
image

</noscript>

image

3. 插入一個(gè)模塊, 處女座可以對(duì)這個(gè)模塊起個(gè)好名字. 老衲是水瓶座, 那就哈哈哈哈啦.

<noscript>
image

</noscript>

image

4. Coding: 時(shí)間緊就不逐一細(xì)說(shuō)了. 還是非常簡(jiǎn)單的. 老衲的注釋率超過(guò)20%啦~

Public Function deduplicate(duplicateWords As String)

'declaim some vars
Dim wArray As Variant

'Split the long string and Write in and deduplicate with dictionary

wArray = Split(duplicateWords, ",")

Set dic = CreateObject("scripting.dictionary")
    For i = 0 To UBound(wArray)
        dic(Trim(wArray(i))) = ""  'Trim the string in case of irragular text
    Next

'Reconstruct the long string
Dim result As String

For Each wItem In dic
   result = result + "," + wItem
Next

deduplicate = Right(result, Len(result) - 1) 'remove the extra comma and return

End Function

5. 這時(shí)候你已經(jīng)有一個(gè)新公式了

<noscript>
image

</noscript>

image

6. 這個(gè)函數(shù)只需要把左邊的列選中, 然后拖動(dòng)一下, 問(wèn)題解決. 完美~~

<noscript>
image

</noscript>

image

如果還有更多問(wèn)題, 請(qǐng)關(guān)注老衲在知乎的專(zhuān)欄~~從點(diǎn)滴開(kāi)始做更好的自己 - 知乎專(zhuān)欄

編輯于 2016-10-19

?贊同 35 ? ?16 條評(píng)論

?分享

?收藏 ?喜歡

?

收起?

<meta itemprop="name" content="黃晨"><meta itemprop="image" content="https://pic4.zhimg.com/v2-20a25efce4b05a573a67c7e9d3be4635_is.jpg"><meta itemprop="url" content="https://www.zhihu.com/people/huangchen1031"><meta itemprop="zhihu:followerCount" content="2265">

黃晨

不答題/不回信/不會(huì)Excel

1 人贊同了該回答

<meta itemprop="image"><meta itemprop="upvoteCount" content="1"><meta itemprop="url" content="https://www.zhihu.com/question/51729819/answer/127369448"><meta itemprop="dateCreated" content="2016-10-19T09:53:04.000Z"><meta itemprop="dateModified" content="2016-10-20T02:10:19.000Z"><meta itemprop="commentCount" content="3">

簡(jiǎn)單寫(xiě)了下,利用字典去重

Function duplicate_removal(ByVal str As String, ByVal sign As String)

Dim strArr, strDic
Set strDic = CreateObject("Scripting.Dictionary")

strArr = Split(str, sign)
For i = 1 To UBound(strArr)
  strDic.Item(strArr(i)) = strArr(i)
Next i

For Each Key In strDic
  duplicate_removal = duplicate_removal + strDic(Key) + sign
Next

duplicate_removal = Left(duplicate_removal, Len(duplicate_removal) - Len(sign))

End Function

使用例子:
對(duì)A1單元格去重,分隔符是中文逗號(hào)
=duplicate_removal(A1,",")

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容