- 帖子
- 4901
- 主題
- 44
- 精華
- 24
- 積分
- 4916
- 點名
- 120
- 作業系統
- Windows 7
- 軟體版本
- Office 20xx
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台北
- 註冊時間
- 2010-4-30
- 最後登錄
- 2025-5-18
               
|
2#
發表於 2012-3-15 19:52
| 只看該作者
回復 1# a703130 - Sub ex()
- Set d = CreateObject("Scripting.Dictionary")
- For Each sh In Sheets
- d(sh.Name) = d.Count
- Next
- With Sheet1
- For Each a In .Range("F:F").SpecialCells(xlCellTypeConstants, xlNumbers)
- If d.exists(a.Offset(, -4).Text) Then
- With Sheets(a.Offset(, -4).Text)
- Set c = .Columns("A").Find(Split(a.Offset(, -5), "_")(1), lookat:=xlWhole)
- If Not c Is Nothing Then
- i = 1
- k = Application.Count(c.Offset(1, 2).Resize(2, 8))
- For x = 2 To 1 Step -1
- For y = 8 To 1 Step -1
- b = c.Offset(1, 2).Resize(2, 8).Cells(x, y)
- If IsNumeric(b) Then
- mystr = IIf(mystr = "", Application.Small(c.Offset(1, 2).Resize(2, 1).EntireRow, i), mystr & "," & Application.Small(c.Offset(1, 2).Resize(2, 1).EntireRow, i))
- i = i + 1
- Else
- mystr = IIf(mystr = "", "", mystr & ",")
- End If
- Next
- Next
- a.Offset(, 1) = mystr
- mystr = ""
- End If
- End With
- Else
- a.Offset(, 1) = ""
- End If
- Next
- End With
- End Sub
複製代碼 |
|