View Single Post
  #7   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

As Sam said, you need to change the Case statements from Case 1, Case 2 and
Case 3 to Case 4, Case 5 and Case 6. The reason is because the Select Case
statement is looking at Target.Column where Target is the cell you changed
and Column is the number that the Target cell is in. The Case statements
represent the possible values that Target.Column can produce (which is 4, 5
and 6 as per your latest post).

By the way, for future reference... don't simply your problem for us when
you ask your question... doing that make additional work for you when you
have to modify any code we offer you and it, as you can now see, gives you
the opportunity to incorrectly try and change that code. Just tell us your
actual set up and what you want to be done with it and let us work with that
directly. And remember, examples are always helpful.

--
Rick (MVP - Excel)


"K" wrote in message
...
Hi rick, thanks for replying. i change you macro little bit but its
not working. i dont need whole column as i just need to specify the
ranges. any suggestion why its not working?

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("D18:F23,D26:F31,D35:F37,D40:F44"))
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