changing a circular funtion into one that works

T

tomvb

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.
 
D

Debra Dalgleish

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
'=========================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top