- 帖子
- 4901
- 主題
- 44
- 精華
- 24
- 積分
- 4916
- 點名
- 142
- 作業系統
- Windows 7
- 軟體版本
- Office 20xx
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台北
- 註冊時間
- 2010-4-30
- 最後登錄
- 2026-7-16
                
|
回復 8# YUPOYU
不是模組位置的關係,是你的欄位起始位置不同- Sub ex()
- Set d = CreateObject("Scripting.Dictionary")
- With Sheet1
- For j = 8 To .[IV5].End(xlToLeft).Column
- For i = 5 To .[G65536].End(xlUp).Row
- If d(.Cells(i, j).Value) = "" Then
- d(.Cells(i, j).Value) = .Cells(i, 7)
- Else
- d(.Cells(i, j).Value) = d(.Cells(i, j).Value) & "," & .Cells(i, 7)
- End If
- Next
- Next
- ay = Split(Join(d.items, ","), ",")
- End With
- With Sheet2
- For Each a In .Range(.[A2], .[IV2].End(xlToLeft))
- If d(a.Value) <> "" Then
- If mystr = "" Then
- mystr = d(a.Value)
- Else
- mystr = mystr & "," & d(a.Value)
- End If
- End If
- Next
- ar = Split(mystr, ",")
- .[A3].Resize(UBound(ar) + 1, 1) = Application.Transpose(ar)
- End With
- End Sub
複製代碼 |
|