主题:菜鸟求助,excel中vb编程运行结果“错误424:要求对象”
Sub EW()
Let maxofx = 10
Let maxofy = 10
Worksheets(1).Activate
Dim h, count As Integer
Dim sum As Double
h = 0
Range("d1") = "h"
Range("e1") = "f(h)"
Do While h < maxofx / 2
h = h + 1
sum = 0
count = 0
Range("a2").Activate
Do While ActiveCel1.Value <= maxofx - h
count = count + 1
sum = sum + WorksheetFunction.Power((ActiveCell.Offset(0, 2) - ActiveCel1.Offset(25 * h, 2)), 2)
ActiveCell.Offset(1, O).Select
Loop
Cells(h + 1, 4) = h * 100
Cells(h + 1, 5) = sum / count / 2
Loop
End Sub
excel表格数据如下:
0 1787 6.56
74 781 7.84
1049 2127 6.35
1321 1791 4.9
1373 731 5.93
1647 2728 14.08
2383 3692 9.62
2427 3971 5.72
2486 5999 5.51
2708 2295 7.41
Let maxofx = 10
Let maxofy = 10
Worksheets(1).Activate
Dim h, count As Integer
Dim sum As Double
h = 0
Range("d1") = "h"
Range("e1") = "f(h)"
Do While h < maxofx / 2
h = h + 1
sum = 0
count = 0
Range("a2").Activate
Do While ActiveCel1.Value <= maxofx - h
count = count + 1
sum = sum + WorksheetFunction.Power((ActiveCell.Offset(0, 2) - ActiveCel1.Offset(25 * h, 2)), 2)
ActiveCell.Offset(1, O).Select
Loop
Cells(h + 1, 4) = h * 100
Cells(h + 1, 5) = sum / count / 2
Loop
End Sub
excel表格数据如下:
0 1787 6.56
74 781 7.84
1049 2127 6.35
1321 1791 4.9
1373 731 5.93
1647 2728 14.08
2383 3692 9.62
2427 3971 5.72
2486 5999 5.51
2708 2295 7.41