Dim col As Integer, p_today As Single, row As Integer
For i = 2 To 9 '在工作表2至工作表9作計算
col = 3
Do While Sheets(i).Cells(1, col) <> ""
If IsNumeric(Sheets(i).Cells(65536, col + 1).End(xlUp).Value) Then '如果是數字
p_today = Sheets(i).Cells(65536, col + 1).End(xlUp).Value '行號(col+1) 存有每天的資料
Else
p_today = 0
End If
Sheets(i).Activate
Sheets(i).Cells(65536, col + 1).End(xlUp).Select
row = Selection.row()
avg = Application.Average(Range(Sheets(i).Cells(row - 259, col + 1), Sheets(i).Cells(row, col + 1)))
Sheets(i).Cells(65536, col).Value = avg '行號col 放置260天平均值
col = col + 2
Loop
Next作者: GBKEE 時間: 2015-3-20 06:43