2

我该如何执行以下操作:

For j = 1 To MaxCol + 1
    'Select the cell on which you want to save the formula

    Cells(7, j).Select

    my_story_tab_array(j) = ActiveCell.FormulaArray
Next

活动工作表中的某些单元格不是公式数组...有些是...

我想将它们保存到我的代码(公共/全局变量)中的数组()中,以便以后可以恢复它们......

TIA。

4

2 回答 2

0

我认为这会对你有所帮助:)

    Sub editedmacro()
    Dim my_story_tab_array() As Variant 'Array where the formula will be store
    MaxCol = 2
    For j = 1 To MaxCol + 1
        ReDim my_story_tab_array(MaxCol + 1) 'set size of the array
        Cells(7, j).Select 'Select the cell on which you want to save the formula

        my_story_tab_array(j) = ActiveCell.FormulaArray 'store the current cell value into array
        MsgBox (my_story_tab_array(j))
    Next
   End Sub

问候

于 2013-07-10T06:57:43.617 回答
0

你在寻找某事。像这样:

Sub example()
With ActiveWorkbook.Sheets(1).Range(Cells(7, 3), Cells(7, 4))
    .Formula = "=SUM($A$2, $A$3) * 9"
    .FormulaArray = .FormulaR1C1
End With
End Sub

问候

于 2013-07-10T18:38:17.647 回答