- 帖子
- 4901
- 主題
- 44
- 精華
- 24
- 積分
- 4916
- 點名
- 142
- 作業系統
- Windows 7
- 軟體版本
- Office 20xx
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台北
- 註冊時間
- 2010-4-30
- 最後登錄
- 2026-7-16
                
|
回復 4# ffntldj
就單純把book2的b工作表中part_id對應modify後3碼填入a工作表的第2、3列- Sub nn()
- Set d = CreateObject("Scripting.Dictionary")
- With Workbooks.Open("D:\book2.xls") '檔案路徑自行修改
- With .Sheets("b")
- For Each a In .Range(.[A1], .[A65536].End(xlUp))
- If a = "part_id" Then mystr = a.Offset(, 1).Text
- If a = "modify" Then
- If d(mystr) = "" Then
- d(mystr) = "'" & Right(a.Offset(, 1), 3) & "'"
- Else
- d(mystr) = d(mystr) & ",'" & Right(a.Offset(, 1), 3) & "'"
- End If
- End If
- Next
- End With
- .Close
- End With
- With Sheets("a")
- k = 2
- For Each ky In d.keys
- .Cells(2, k) = ky
- .Cells(3, k) = "(" & d(ky) & ")"
- k = k + 1
- Next
- End With
- End Sub
複製代碼 |
|