Excel刪除重複值

2022-08-01 21:51:19 字數 572 閱讀 6433

sub uniquedata()

dim rcell as range

'建立dictionary物件

set d = createobject("scripting.dictionary")

'遍歷資料區域的單元格

for each rcell in range("a2:i905")

'判斷單元格是否為空

if rcell <> "" then

'如果dictionary物件中不包含指定的關鍵字就新增該關鍵字和條目

if not d.exists(rcell.value) then d.add rcell.value, rcell.value

end if

next

'清除指定列內容

range("j2:j" & range("j2").end(xldown).row).clearcontents

'將dictionary物件中的條目寫入指定列

range("j2").resize(d.count) = worksheetfunction.transpose(d.items)

end sub

excel中刪除重複資料

今天碰到的乙個問題,刪除重複資料,這裡做個記錄。一列資料,有很多重複專案,現在需要刪除重複的,如下圖所示 簡單的方法是,選中該列,工具欄 資料 專案中選擇 刪除重複項 按下確定 按下確定完成重複專案的清理 那麼從vba的角度如何刪除資料 測試用新增資料如下 sub adddata dim i as ...

刪除list中重複的值

方法一 迴圈元素刪除 刪除arraylist中重複元素 public static void removeduplicate list list system.out.println list 方法二 通過hashset剔除 刪除arraylist中重複元素 public static void r...

datagridview列 值提取 刪除重複值演示

有時候需要對一列資料內容進行提取唯一的值,比如統計下表c列的人名,因為裡面有重複出現的人名,統計的時候,就不能按照計數的方式進行統計。自excel2007版本以後,出現了一些智慧型工具按鈕。這個刪除重複項就是其中之一,用起來還是挺方便的。先看演示 由這個圖上可以看到,c列的內容一共有13個重複值,刪...