Re: [算表] excel 從A表帶資料到B表某欄位

作者: cutekid (可愛小孩子)   2023-10-17 12:00:10
VBA 解法:
Sub demo()
Set d = CreateObject("Scripting.Dictionary")
a = Sheets("A").UsedRange
For i = 1 To UBound(a)
For j = 1 To UBound(a, 2)
Key = a(i, j)
If Key = "" Then: Exit For
If d.exists(Key) Then: d(Key) = d(Key) & ","
d(Key) = d(Key) & a(i, 1)
Next
Next
With Sheets("B")
For i = 1 To .[a1].End(4).Row
.Cells(i, 2) = d(.Cells(i, 1).Value)
Next
End With
End Sub
※ 引述《chueight (baba)》之銘言:
: 軟體:excel
: 版本:2016
: 各位神人身為鏟表新手的我有個問題
: 有兩表AB
: A表資料如下(已經整理成不同欄)
: 甲 1 2 3
: 乙 2 3
: 丙 4
: 丁 1 2 5
: B表資料如下
: 1
: 2
: 4
: 5
: 3
: 請問B表如何套用公式或vba 整理(兩欄)
: 1 甲,丁
: 2 甲,乙,丁
: 4 丙
: 5 丁
: 3 甲,乙
: 以上虛心受教,感謝ptt
:
作者: chueight (baba)   2023-10-31 14:59:00
再謝一次!

Links booklink

Contact Us: admin [ a t ] ucptt.com