---
title: "translate_formula"
---

[< Back to Reference](../reference.qmd) | [View source](https://codeberg.org/usrbinr/tidychain/src/branch/main/R/formula_translate.R#L21)

# `translate_formula()`

Translate Excel Formula to R

## Usage

```r
translate_formula(formula, cell_mapping = NULL)
```

## Arguments

| Argument | Description |
|----------|-------------|
| `formula` | An Excel formula string. |
| `cell_mapping` | Optional named list mapping cell refs to R variable names. |

## Value

A list with:

- `r_code`: The translated R code (or NA if translation failed)

- `success`: TRUE if translation was successful

- `notes`: Any notes or warnings about the translation

## Description

Attempts to translate an Excel formula to equivalent R code.
Not all formulas can be translated automatically.

## Examples

```r
translate_formula("A1+B1")
translate_formula("SUM(A1:A10)")
translate_formula("IF(A1>0,B1,C1)")
```

