|
楼主 |
发表于 2018-6-20 20:27
|
显示全部楼层
Sub caltrend()
Dim sh As Worksheet
Dim i, k, m, n As Integer
Dim d_num, r_num As Integer
Application.ScreenUpdating = False
For k = 3 To Sheets.Count
Set sh = Sheets(k)
d_num = 7
'd_num是天数(取的数据范围),n是结束列,m是开始列
n = sh.Cells(1, 1).End(xlToRight).Column - 1
m = n - d_num + 1
r_num = sh.Cells(1, 1).End(xlDown).Row
sh.Columns(n + 2).Delete
For i = 2 To r_num
ave = Application.Round((ave, 0), (sh.Cells(i, n - 1) /(d_num - 1)))
'Application.Round(ave, 0)四舍五入取整
sh.Cells(1, n + 2).Value = "前6天均值"
newd = sh.Cells(i, n)
If newd > ave * 1.3 And newd > 3 Then
sh.Cells(i, n + 2).Interior.Color = RGB(204, 0, 0)
End If
Next i
Next
Application.ScreenUpdating = True
End Sub
那句还是有问题,大神再帮忙看看 |
|