Excel VBA – 尝试将系列公式指定给单元格值时,运行时错误1004

我坚持运行时错误代码1004:应用程序定义或对象定义。

当我尝试获取所有图表的所有系列值时,我需要将其粘贴到单元格以便于监视。 一切工作正常,但当我尝试给单元格的值与系列值相等时卡住了。

例:

Dim xchart As ChartObject For Each xchart In ActiveSheet.ChartObjects Dim ser As Series For Each ser In xchart.Chart.SeriesCollection ...... Sheet1.Range("a1").Value = ser.Formula ' Run-time Error Occur .... Next ser Next xchart 

有人能帮我解决这个问题吗?

使用

 Sheet1.Range("a1").Value = "'" & ser.Formula 

在单元格中存储文本值

否则会将其解释为(未知)公式