我试图获得与其他宏观一些数据我输入到2维数组,所以我可以再申请一个功能,即数据,但无论我怎么努力我不断收到错误。数据包括字符串和数字。我总是可以参考单元格并忘记数组,但这会使函数复杂化。这里是我的代码:分配值2维数组
(声明)
Dim nLiens As Byte, nCreditors As Byte
Dim SecurityV As Currency, ASecurityV As Currency
Const adjuster = 0.9
(相关潜艇)
Public Sub VariableDeclaration()
nLiens = InputBox("Enter number of liens in security")
nCreditors = InputBox("Enter number of creditors")
SecurityV = InputBox("Enter security full value")
ASecurityV = adjuster * SecurityV
Call ODebt
End Sub
Sub ODebt()
'
'(...)
'
Dim oDebt() As Variant
ReDim oDebt(1 To nCreditors + 1, 1 To nLiens + 1)
Dim rg As Range
Set rg = Range(Cells(1, 1), Cells(nCreditors + 1, nLiens + 1))
oDebt = rg.Value
MsgBox (oDebt)
'>>> ERROR: type mismatch
Call SAllocation
End Sub
我已经尝试过其他的替代品,比如有两个设置由单元格的内容细胞“对于”循环和LBound
和UBound
,但似乎没有任何工作。
我明白了!谢谢!! – Migarisa
如果这回答你的问题,请将其标记为未来读者解决! – Verzweifler