问题描述:

Is there a way to skip a step of inserting a R1C1 formula into range but insert only formula results? What I have now:

newColumn.FormulaR1C1 = "=MID(RC[-17],14,3)"

newColumn.Value = newColumn.Value

I'd like to have something like:

newColumn.Value = newColumn.FormulaR1C1 = "=MID(RC[-17],14,3)"

网友答案:

newColumn.Value = evaluate("MID(RC[-17],14,3)")

网友答案:

Here is how to convert R1C1 formula to A1 type:

Function MakeA1(R1C1Formula As String) As String

MakeA1 = Application.ConvertFormula( _
    Formula:=R1C1Formula, _
    fromReferenceStyle:=xlR1C1, _
    toReferenceStyle:=xlA1, _
    ToAbsolute:=xlAbsolute)    
End Function

Then you can use it so:

Sub test()
    str1 = MakeA1("MID(RC[-17],1,3)")
    Range("B2").Value = Evaluate(str1)
End Sub
相关阅读:
Top