Excel – user input but retain formula for two circular cells

microsoft excel

I'm trying to make two cells retain background formula after user input and has a circular formula.

A1 = Lbs
A2 = Kgs

Formula
A1 = A2*2.2
A2 = A1/2.2

I know about the thread below but I cannot get this to work for circular formulas.
I have enabled use iterative calculation in preference.
Excel – how to either have direct data input or cell value from formula

Best Answer

Excel does not work like this.

If both cells have formulas then there is nowhere to get an input value from. That's why this will not work with circular references.

A cell can either have a formula or a value. If you enter a value into a cell that has a formula, the formula will be overwritten. What you are trying to achieve will require at least 3 cells: an entry cell for the value, a cell for the unit and a third cell for the conversion result. You may even want to add a fourth cell for the unit of the result. Consider this screenshot:

The Value is entered in B2, the unit of the value is specified in C2. The conversion is calculated in B3

=IF(C2="lbs",B2/2.2,B2*2.2)

The unit of the result is calculated in C3 with =IF(C2="Kgs","Lbs","Kgs"), but that bit is optional.

enter image description here

Edit: You can use VBA to convert the value and place it in the other cell. This can be done without writing a formula into the cell, though. If you already use VBA, you might as well do the calculation in VBA instead of using VBA to write a formula into a cell. Here is the VBA for that:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not Intersect(Target, Range("A1:A2")) Is Nothing Then
    If Target.Count = 1 Then
        Application.EnableEvents = False
        If Target.Row = 1 Then
            Target.Offset(1, 0) = Target / 2.2
        Else
            Target.Offset(-1, 0) = Target * 2.2
        End If
        Application.EnableEvents = True
    End If

End If
End Sub
Related Question