- 帖子
- 4901
- 主題
- 44
- 精華
- 24
- 積分
- 4916
- 點名
- 119
- 作業系統
- Windows 7
- 軟體版本
- Office 20xx
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台北
- 註冊時間
- 2010-4-30
- 最後登錄
- 2025-5-17
               
|
9#
發表於 2011-1-17 16:19
| 只看該作者
回復 8# candy516 - Sub ex()
- Set d = CreateObject("Scripting.Dictionary")
- Application.ScreenUpdating = False
- With Sheet1
- For Each a In .Range(.[A2], .[A2].End(xlDown))
- d(a & Year(a.Offset(, 1))) = Array(a.Offset(, 1), a.Offset(, 2))
- Next
- End With
- For y = 2001 To 2010
- With Sheets(CStr(y))
- If Application.CountBlank(.Range(.[B1], .[IV1].End(xlToLeft))) > 0 Then .Range(.[B1], .[IV1].End(xlToLeft)).SpecialCells(xlCellTypeBlanks).EntireColumn.Delete
- .Range(.[IV1].End(xlToLeft).Offset(, 1), .[IV1]).EntireColumn.Clear
- k = 2
- Do Until .Cells(1, k) = ""
- .Columns(k + 1).Insert
- mystr = .Cells(1, k) & y
- Set a = .Columns("A").Find(d(mystr)(0))
- If Not a Is Nothing Then
- cnt = 0
- r = a.Row
- test = .Cells(r - 1, k)
- r = r + 1
- cnt = cnt + 1
- Do Until .Cells(r, k) >= test Or .Cells(r, k) = ""
- cnt = cnt + 1
- r = r + 1
- Loop
- If .Cells(r, 1) = "" Then
- .Cells(a.Row, k + 1) = "無填權"
- Else
- .Cells(a.Row, k + 1) = cnt
- End If
- End If
- k = k + 2
- Loop
- End With
- Next
- Application.ScreenUpdating = True
- End Sub
複製代碼 |
|