Application.ConvertFormula (Excel)
Converts cell references in a formula between the A1 and R1C1 reference styles, between relative and absolute references, or both.
There is a 255 character limit for the formula.
ConvertFormula (Formula, FromReferenceStyle, ToReferenceStyle, ToAbsolute, RelativeTo)
inputFormula = "=SUM(R10C2:R15C2)"
MsgBox Application.ConvertFormula( _
formula:=inputFormula, _
fromReferenceStyle:=xlR1C1, _
toReferenceStyle:=xlA1)
Arguments
The following arguments are required:
Formula (String) - A string that contains the formula that you want to convert. This must be a valid formula, and it must begin with an equal sign.
FromReferenceStyle (XlReferenceStyle) - The reference style of the formula.
Possible return values are xlA1 - Default. Use xlA1 to return an A1-style reference, xlR1C1 - Use xlR1C1 to return an R1C1-style reference.
Optional arguments
The following arguments are optional
ToReferenceStyle (XlReferenceStyle) - A constant of XlReferenceStyle specifying the reference style that you want returned. If this argument is omitted, the reference style isn't changed; the formula stays in the style specified by FromReferenceStyle.
Possible return values are xlA1 - Default. Use xlA1 to return an A1-style reference, xlR1C1 - Use xlR1C1 to return an R1C1-style reference.
ToAbsolute (XlReferenceType) - A constant of XlReferenceType that specifies the converted reference type. If this argument is omitted, the reference type isn't changed.
Possible values are
xlAbsolute | Convert to absolute row and column style. |
xlAbsRowRelColumn | Convert to absolute row and relative column style. |
xlRelative | Convert to relative row and column style. |
xlRelRowAbsColumn | Convert to relative row and absolute column style. |
RelativeTo (Range) - A Range object that contains one cell. Relative references relate to this cell.