将A1公式和数组转换为L1C1公式,反之亦然

时间:2011-07-02 20:07:05

标签: excel vba excel-vba ms-office excel-2007

有没有办法将时尚A1公式和数组转换为时尚L1C1公式,反之亦然?

3 个答案:

答案 0 :(得分:3)

Application.ConvertFormula Method

Application.ConvertFormula(Formula, FromReferenceStyle, ToReferenceStyle, ToAbsolute, RelativeTo)

答案 1 :(得分:0)

不确定我是否完全理解这个问题,但您可以使用以下方法的组合来交换单元格/范围的公式类型

Sub test()
With Sheet1
    Set Rng = .Range("A1")

    'method1
    Formula = Rng.FormulaR1C1
    Rng.FormulaR1C1 = Formula

    'method2
    Formula = Rng.FormulaR1C1
    Rng.Formula = Formula

    'method3
    Formula = Rng.Formula
    Rng.Formula = Formula

    'method4
    Formula = Rng.Formula
    Rng.FormulaArray = Formula

End With
End Sub

答案 2 :(得分:0)

通过Chance,我正在寻找“VBA和Macros for Microsoft Office Excel 2007 - Bill Jelen”一书,他说: 1)在编辑VBA中; 2)键入CTRL + G; 3)键入“Print ActiveCell.FormulaL1C1”; 4)按Enter键;