View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default Putting Formula in all cells give Circular Reference. Please help

Here is a minor change in my code which allows you to delete an entry and
not get zeroes in the other two cells (everything else works the same as in
my previously posted code)...

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A:C")) Is Nothing Then
On Error GoTo Whoops
Application.EnableEvents = False
If Target = "" Then
Range("A" & Target.Row & ":C" & Target.Row).ClearContents
Else
Select Case Target.Column
Case 1
Target.Offset(, 1) = Target * 52 / 12
Target.Offset(, 2) = Target / 37
Case 2
Target.Offset(, -1) = Target * 12 / 52
Target.Offset(, 1) = Target * 12 / (37 * 52)
Case 3
Target.Offset(, -2) = 37 * Target
Target.Offset(, -1) = 37 * 52 * Target / 12
End Select
End If
End If
Whoops:
Application.EnableEvents = True
End Sub

--
Rick (MVP - Excel)


"Rick Rothstein" wrote in message
...
Just guessing here, but I assume you want this functionality for all the
rows in Columns A through C. You can do that using VB event code. Right
click the tab at the bottom of the worksheet you want this functionality
on and select View Code from the pop up window that appears, then
Copy/Paste the following code into the code window that appeared...

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A:C")) Is Nothing Then
On Error GoTo Whoops
Application.EnableEvents = False
Select Case Target.Column
Case 1
Target.Offset(, 1) = Target * 52 / 12
Target.Offset(, 2) = Target / 37
Case 2
Target.Offset(, -1) = Target * 12 / 52
Target.Offset(, 1) = Target * 12 / (37 * 52)
Case 3
Target.Offset(, -2) = 37 * Target
Target.Offset(, -1) = 37 * 52 * Target / 12
End Select
End If
Whoops:
Application.EnableEvents = True
End Sub

Now, go back to the worksheet and type a number into either Column A, B or
C and watch the other columns fill in automatically. By the way, I presume
that you have the cells in those columns formatted the way you want (one
decimal place in Columns A and B and one decimal place percentage in
Column C as your example data shows).

--
Rick (MVP - Excel)


"K" wrote in message
...
I have figures in cell A1 , B1 & C1 (see below)
A B C…col
2.0 8.7 5.4%

in cell A1 I have nothing , in cell B1 I have formula "=A1*52/12" and
in cell C1 again I have formula "=(B1*12)/(37*52)"

As I got formulas in cell B1 & C1 so when ever I put any figure in
cell A1, I get figures automatically appearing in other cells as shown
above if I put 2.0 in cell A1 then I get 8.7 in B1 and 5.4% in C1. I
want to put formula in cell A1 as well and want to chane formulas in
cells B1 and C1 little bit so like this i'll have formulas in all
three cells. I want this because lets say if user put 8.7 in cell B1
then i want 2.0 to automatically appear in cell A1 and 5.4% to in C1.
In other words if user put figure any one of three cells then i want
remaing cells to produce result automatically. I tried putting
formulas in all three cells put i get circular reference error. I
know i can get rid of by ticking box of iterative calculation in
options but then i'll get different results. Is there any way that i
can have formulas in all three cells and if any one of the cells value
get change manually then remaing two show the correct results. and i
want this without having circular reference error. Please can any
friend can help