如何执行以下操作:
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。
我认为这将对您有所帮助:)
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
问候
你正在搜索这样的东西:
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
问候