Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个宏可以做到这一点:
ActiveCell.FormulaR1C1 = "=COVAR(" & ticker & "!I:I," & MarketIndex & "!I:I)/VARP(" & MarketIndex & "!I:I)"
其中插入:
=COVAR(BMY!I:I,GSPC!I:I)/VARP(GSPC!I:I)
但它显示为#NAME?直到我单击单元格以显示公式并按 Enter 键。为什么它不会在没有干预的情况下自动运行?
#NAME?
您正在尝试将A1样式引用分配给R1C1样式属性,您不能混合使用这些类型。
A1
R1C1
要么使用
ActiveCell.Formula = "=COVAR(" & ticker & "!I:I," & MarketIndex & "!I:I)/VARP(" & MarketIndex & "!I:I)"
或者
ActiveCell.FormulaR1C1 = "=COVAR(" & ticker & "!C9," & MarketIndex & "!C9)/VARP(" & MarketIndex & "!C9)"