我为存款计算的Excel 2010 VBA功能实现了一个编译错误。 我想返回一个包含利率的数组及其给定存款的价值。
Function exe3djxInterestSelect(deposite)
Dim V() As Variant
ReDim V(1, 2)
Select Case deposite
Case Is < 0
exe3djxInterestSelect = CVErr(xlErrNum)
Case 0 To 1000
V(1) = 0.055
V(2) = deposite * 0.055
exe3djxInterestSelect = V
Case 1000 To 10000
V(1) = 0.063
V(2) = deposite * 0.063
exe3djxInterestSelect = V
Case 10000 To 100000
V(1) = 0.073
V(2) = deposite * 0.073
exe3djxInterestSelect = V
Case Else
V(1) = 0.078
V(2) = deposite * 0.078
exe3djxInterestSelect = V
End Select
结束功能
它返回#VALUE! 。
它出了什么问题?
由于
答案 0 :(得分:1)
你正在混合一维和二维数组:试试这个
Function exe3djxInterestSelect(deposite)
Dim V() As Variant
ReDim V(1 To 1, 1 To 2)
Select Case deposite
Case Is < 0
exe3djxInterestSelect = CVErr(xlErrNum)
Case 0 To 1000
V(1, 1) = 0.055
V(1, 2) = deposite * 0.055
exe3djxInterestSelect = V
Case 1000 To 10000
V(1, 1) = 0.063
V(1, 2) = deposite * 0.063
exe3djxInterestSelect = V
Case 10000 To 100000
V(1, 1) = 0.073
V(1, 2) = deposite * 0.073
exe3djxInterestSelect = V
Case Else
V(1, 1) = 0.078
V(1, 2) = deposite * 0.078
exe3djxInterestSelect = V
End Select
End Function