changing a circular funtion into one that works

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a WS that looks like this
A B C
1 Net Sales: 1,411,676

2 Salaries: 52,800 3.74%

There are many other rows, but basically C2 is the percentage B2 is of B1.

My boss wants to be able to change eiter B2 or C2 and have it change the other.
The formals are:
B2= B1 * C2
C2= B2 / B1

I so not know how to make this work. I would appreciat any suggestions.
 
You could use a Worksheet_Change event to do this. Right-click on the
sheet tab, and choose View Code. Paste the following code onto the
module sheet, where the cursor is flashing.

'===========================================
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ChangeExit
Application.EnableEvents = False
If Target.Count > 1 Then Exit Sub
If Target.Address = "$B$2" Then
Range("C2").Formula = "=B2/B1"
End If
If Target.Address = "$C$2" Then
Range("B2").Formula = "=B1*C2"
End If

ChangeExit:
Application.EnableEvents = True

End Sub
'=========================
 
Back
Top