任何人都可以通过我的以下查询帮助我。
我正在尝试将数组公式分配给b3变量,但无法使其工作。我以前在我编写的其他脚本中的特定单元格实例中使用过.formulaarray但是我想知道如何在下面的代码中为该变量分配一个arrayformula。
b3 =“= if($ C $”& OffsetValue - 1&“= C $”& OffsetValue - 1&“,PRODUCT(1 + $ C”& OffsetValue + 1 + i& “:C $”& OffsetValue + 1 + i&“)-1,C $”& OffsetValue + 1 + i&“)”
任何人都可以帮助我吗?
由于
Sub performancefees()
Dim i As Integer
Dim f As Range, rng As Range
Dim wb As Workbook
Dim ws As Worksheet, CtrlWs As Worksheet
Dim fund As String
Dim offset As Integer
Dim ModelStart As Date, ModelEnd As Date
'Dim a As variable
OffsetValue = 10
i = 1
Set rng = Range("Funds")
Sheets("FeeCalc").Activate
CtrlSheet = "Control"
Set CtrlWs = ActiveWorkbook.Worksheets(CtrlSheet)
ModelStart = CtrlWs.Range("C3")
ModelEnd = CtrlWs.Range("C4")
For Each f In rng
Dim calc
b1 = "=INDEX(INDIRECT($A" & OffsetValue + i & " &""_Financials""),MATCH(""Total unitholders' funds"",INDIRECT($A" & OffsetValue + i & "&""_Financials_Desc""),0),MATCH(EOMONTH(C$" & OffsetValue & " ,0),INDIRECT($A" & OffsetValue + i & "&""_Financials_Timeline""),0))"
b2 = "= " & f & "_Benchmark/12"
b3 = "=if($C$" & OffsetValue - 1 & "=C$" & OffsetValue - 1 & ",PRODUCT(1+$C" & OffsetValue + 1 + i & ":C$" & OffsetValue + 1 + i & ")-1,C$" & OffsetValue + 1 + i & ")"
b4 = "=INDEX(INDIRECT($A" & OffsetValue + i & " &""_Financials""),MATCH(""Fund Total Return (post base management fee)"",INDIRECT($A" & OffsetValue + i & "&""_Financials_Desc""),0),MATCH(EOMONTH(C$" & OffsetValue & " ,0),INDIRECT($A" & OffsetValue + i & "&""_Financials_Timeline""),0))"
b5 = ""
b6 = "=(C" & OffsetValue + 3 + i & "-C" & OffsetValue + 1 + i & ")*C" & OffsetValue + i & " "
b7 = "=(C" & OffsetValue + 4 + i & "-C" & OffsetValue + 2 + i & ")*C" & OffsetValue + i & " "
b8 = "=INDEX(INDIRECT($A" & OffsetValue + i & " &""_Financials""),MATCH(""Management fee"",INDIRECT($A" & OffsetValue + i & "&""_Financials_Desc""),0),MATCH(EOMONTH(C$" & OffsetValue & " ,0),INDIRECT($A" & OffsetValue + i & "&""_Financials_Timeline""),0))"
b9 = "=C" & OffsetValue + i & "*" & f & "_PFValCap"
b10 = "=min(C" & OffsetValue + 7 + i & ",C" & OffsetValue + 8 + i & "-C" & OffsetValue + 7 + i & ")"
b11 = "=C" & OffsetValue + 6 + i & "*" & f & "_PerfFee"
b12 = "Minimum Fund Performance Satisfied?"
b13 = "Performance Fee Cap Applies?"
b14 = "Actual Capped PF"
For Each calc In Array(b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14)
f = f
Range(Cells(OffsetValue + i, 3), Cells(OffsetValue + i, LastColumn)) = Array(calc)
i = i + 1
Next calc
Next f
End Sub
答案 0 :(得分:0)
这是一个非常简化的版本,展示了如何将一个公式切换为数组公式:
AsyncListener