現在遇到了一個問題耶,如果我的實際讀書時間是在sheet3,改成下列就出現錯誤了!!
For Each a In .Sheets("sheet3").Range(.[H2], .[H65536].End(xlUp))
彈出→視窗說找不到方法或資料成員
若改成下列
For Each a In Sheets("sheet3").Range(.[H2], .[H65536].End(xlUp))
彈出→物件或應用程式定義上的錯誤
https://sites.google.com/site/yanto913/data/Plan2.xls作者: yanto913 時間: 2010-9-19 23:18
我弄好了,原來是要貼在來源那邊,然後我把With Sheet3拿掉了
Sub Ex()
Set dic = CreateObject("Scripting.Dictionary")
Set dicn = CreateObject("Scripting.Dictionary")
For Each a In Sheets("sheet3").Range([H2], [H65536].End(xlUp))
dic(a & a.Offset(, 1)) = dic(a & a.Offset(, 1)) + a.Offset(, 2)
Next
For Each a In Sheets("sheet1").Range(Sheets("sheet1").[A2], Sheets("sheet1").[A65536].End(xlUp))
dicn(a & a.Offset(, 1)) = dicn(a & a.Offset(, 1)) + 1
Next
For Each a In Sheets("sheet1").Range(Sheets("sheet1").[A2], Sheets("sheet1").[A65536].End(xlUp))
If a <> "" Then
mytime = Application.Min(a.Offset(, 4), dic(a & a.Offset(, 1)))
If dicn(a & a.Offset(, 1)) = 1 Then
a.Offset(, 5) = Val(dic(a & a.Offset(, 1)))
Else
a.Offset(, 5) = mytime
dicn(a & a.Offset(, 1)) = dicn(a & a.Offset(, 1)) - 1
dic(a & a.Offset(, 1)) = dic(a & a.Offset(, 1)) - mytime
End If
End If
Next
End Sub