0

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! を返します。.

何が問題なのですか?

ありがとう

4

1 に答える 1

1

1 次元配列と 2 次元配列を混同しています: これを試してください

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
于 2013-02-08T17:33:04.330 に答える