好的,从我读到的所有内容来看,将数组从一个子对象传递到另一个子对象很容易,但是当我尝试在此处执行此操作时,VBA宏窗口将打开并停止我的代码。
我尝试阅读其他所有试图解决此问题的内容,但是对()
的定义或删除没有帮助。
Sub Costs__Max_Legal_Physical_Possession_Period(arrCosts__Physical_Possession(), arrCosts__Legal_Possession())
arrQuarters = Range("Quarters_1to40")
arrPhysical_Possession_Expenses_From_Quarter = Range("Costs.Physical_Possession_Expenses_From_Quarter")
arrPhysical_Possession_Expenses_To_Quarter = Range("Costs.Physical_Possession_Expenses_To_Quarter")
arrLegal_Possession_Expenses_From_Quarter = Range("Costs.Legal_Possession_Expenses_From_Quarter")
arrLegal_Possession_Expenses_To_Quarter = Range("Costs.Legal_Possession_Expenses_To_Quarter")
ReDim arrCosts__Max_Legal_Possession(1 To UBound(arrLegal_Possession_Expenses_To_Quarter, 1), 1 To UBound(arrQuarters, 2))
For I = LBound(arrLegal_Possession_Expenses_To_Quarter, 1) To UBound(arrLegal_Possession_Expenses_To_Quarter, 1)
For J = LBound(arrQuarters, 2) To UBound(arrQuarters, 2)
arrCosts__Max_Legal_Possession(I, J) = WorksheetFunction.Max(arrCosts__Physical_Possession(I, J), arrCosts__Legal_Possession(I, J))
Next
Next
End Sub
完整代码
Sub Costs__Legal_Possession()
Dim arrQuarters, arrLegal_Possession_Expenses_From_Quarter, arrLegal_Possession_Expenses_To_Quarter, arrCosts__Legal_Possession, I, J
arrQuarters = Range("Quarters_1to40")
arrLegal_Possession_Expenses_From_Quarter = Range("Costs.Legal_Possession_Expenses_From_Quarter")
arrLegal_Possession_Expenses_To_Quarter = Range("Costs.Legal_Possession_Expenses_To_Quarter")
ReDim arrCosts__Legal_Possession(1 To UBound(arrLegal_Possession_Expenses_To_Quarter, 1), 1 To UBound(arrQuarters, 2))
For I = LBound(arrLegal_Possession_Expenses_To_Quarter, 1) To UBound(arrLegal_Possession_Expenses_To_Quarter, 1)
For J = LBound(arrQuarters, 2) To UBound(arrQuarters, 2)
arrCosts__Legal_Possession(I, J) = (arrQuarters(1, J) >= arrLegal_Possession_Expenses_From_Quarter(I, 1)) * (arrQuarters(1, J) <= arrLegal_Possession_Expenses_To_Quarter(I, 1)) * 1
Next
Next
End Sub
Sub Costs__Physical_Possession()
Dim arrQuarters, arrPhysical_Possession_Expenses_From_Quarter, arrPhysical_Possession_Expenses_To_Quarter, arrCosts__Physical_Possession, I, J
arrQuarters = Range("Quarters_1to40")
arrPhysical_Possession_Expenses_From_Quarter = Range("Costs.Physical_Possession_Expenses_From_Quarter")
arrPhysical_Possession_Expenses_To_Quarter = Range("Costs.Physical_Possession_Expenses_To_Quarter")
ReDim arrCosts__Physical_Possession(1 To UBound(arrPhysical_Possession_Expenses_To_Quarter, 1), 1 To UBound(arrQuarters, 2))
For I = LBound(arrPhysical_Possession_Expenses_To_Quarter, 1) To UBound(arrPhysical_Possession_Expenses_To_Quarter, 1)
For J = LBound(arrQuarters, 2) To UBound(arrQuarters, 2)
arrCosts__Physical_Possession(I, J) = (arrQuarters(1, J) >= arrPhysical_Possession_Expenses_From_Quarter(I, 1)) * (arrQuarters(1, J) <= arrPhysical_Possession_Expenses_To_Quarter(I, 1)) * 1
Next
Next
End Sub
Sub Costs__Max_Legal_Physical_Possession_Period(arrCosts__Physical_Possession(), arrCosts__Legal_Possession())
arrQuarters = Range("Quarters_1to40")
arrPhysical_Possession_Expenses_From_Quarter = Range("Costs.Physical_Possession_Expenses_From_Quarter")
arrPhysical_Possession_Expenses_To_Quarter = Range("Costs.Physical_Possession_Expenses_To_Quarter")
arrLegal_Possession_Expenses_From_Quarter = Range("Costs.Legal_Possession_Expenses_From_Quarter")
arrLegal_Possession_Expenses_To_Quarter = Range("Costs.Legal_Possession_Expenses_To_Quarter")
ReDim arrCosts__Max_Legal_Possession(1 To UBound(arrLegal_Possession_Expenses_To_Quarter, 1), 1 To UBound(arrQuarters, 2))
For I = LBound(arrLegal_Possession_Expenses_To_Quarter, 1) To UBound(arrLegal_Possession_Expenses_To_Quarter, 1)
For J = LBound(arrQuarters, 2) To UBound(arrQuarters, 2)
arrCosts__Max_Legal_Possession(I, J) = WorksheetFunction.Max(arrCosts__Physical_Possession(I, J), arrCosts__Legal_Possession(I, J))
Next
Next
End Sub