[英]VBA - Find all values on column B for article on column A and place them to a single row
我有一個非常大的Excel文檔(2萬個條目),其數據類似於以下內容:
ARTICLE TIME
article 1 1s
article 1 2s
article 2 1s
article 2 2s
article 2 3s
...
我需要從articles列中提取唯一值,並將其對應的時間值放在一行中,如下所示:
ARTICLE TIMES
article 1 1s 2s
article 2 1s 2s 3s
...
我嘗試使用公式(INDEX,MATCH,FIND等...),但沒有得到任何正確的結果。
我如何使用VBA做到這一點(也許?)謝謝。
在“單擊之前”事件中嘗試以下代碼:
cnt = 8
For i = 2 To 6
strg = strg & Cells(i, 2)
If Cells(i, 1) <> Cells(i + 1, 1) Then
Cells(cnt, 1) = Cells(i, 1)
Cells(cnt, 2) = strg
strg = ""
cnt = cnt + 1
End If
Next
時間值在每個文章的單個單元格中填充
這是不使用VBA的食譜
為每篇文章建立匯總時間
ARTICLE TIME SAME TIMES article 1 1s =if(A3=A2;"YES";"") =B2 article 1 2s =if(A3=A2;"YES";"") = if(A3=A2;Concatenate(B3;" ";D2);B3) article 1 3s =if(A4=A3;"YES";"") = if(A4=A3;Concatenate(B4;" ";D3);B4) article 2 1s (extend the formulas down to the end of range)
創建一個副本,將CAME和TIMES中的公式替換為結果選擇列C和D菜單->復制選擇列C和D再次菜單->粘貼特殊; 僅值
按“相同”對列表進行排序(這會將所有“是”放在一個塊中)
刪除所有SAME =“ YES”列
排序回升序的文章列表
刪除“時間”和“是”列
完成。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.