|
楼主 |
发表于 2012-1-17 15:03
|
显示全部楼层
本帖最后由 nanfanglang 于 2012-1-17 15:12 编辑
您好 帮忙看看下面 如何在别的模块引用re(i)数组呢?运行下面的代码到了re(i)说没定义(子过程或函数没定义)
Sub main()
Application.ScreenUpdating = False
Sheets("sheet1").Select
t = Timer
Dim re() As Single, arr
xrow = Range("e:e").End(xlDown).Row
' arr = Range("e1:e" & xrow)
arr = Range("e2:e" & xrow)
ReDim re(1 To xrow - 1)
For i = 1 To xrow - 1
re(i) = arr(i, 1)
Next i
For i = 500 To xrow - 1
youhua (i)
'调用youhua函数
Next i
Range("m3") = Timer - t
MsgBox "程序运行时间:" & Range("m3")
End Sub
Public Function youhua(ByVal kd As Integer) As Integer
Dim i, k, l, EMAA, EMAB As Integer
Dim sy, sumb, sums As Single
Dim rm(), rn(), ro(), rp(), rq(), rr(), rs(), rt(), ru(), arr(12 To 100, 20 To 200) As Single
xrow = Range("e:e").End(xlDown).Row
ReDim rm(1 To xrow - 1), rn(1 To xrow - 1), ro(1 To xrow - 1), rp(1 To xrow - 1), rq(1 To xrow - 1), rr(1 To xrow - 1), rs(1 To xrow - 1)
ReDim rt(1 To xrow - 1), ru(1 To xrow - 1)
For i = 11 To kd
If i = 11 Then
rm(i) = re(i)
rn(i) = re(i)
Else
rm(i) = rm(i - 1) * (12 - 1) / (12 + 1) + re(i) * 2 / (12 + 1)
rn(i) = rn(i - 1) * (26 - 1) / (26 + 1) + re(i) * 2 / (26 + 1)
End If
If i > 25 Then ro(i) = rm(i) - rn(i)
If ro(i) > 0 Then
rq(i) = 1
Else: If ro(i) < 0 Then rq(i) = -1
End If
Next i
End Function
|
|