View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
monir monir is offline
external usenet poster
 
Posts: 215
Default Implied Circular Reference ... in w/s SelectionChange Event

Simply include the list of rows in the common denominator "Case" statement.
If, for example, "dFactor = 50." for "Case 7" and "Case 33", then "Case 7"
line in the w/s Change event code would read: "Case 7, 33", and delete "Case
33". I was'nt aware of the Case expression list!

Thanks again for your help


"monir" wrote:

JE McGimpsey;

Your code works absolutely perfect! and it does exactly what I'm asking for.

Here is just a thought. If, for example, the value of "dFactor" is the same
for ""Case 7" and "Case 33" in your code, Can I combine both statements?
This would be helpful in situations where, for example, there are say 30
paired cells but only a few values of "dFactor".

Once again, thank you kindly for your tremendous help and patience.
Clrealy, you're very knowledgeable and very experienced on the subject matter.

.

"JE McGimpsey" wrote:

It would be difficult to "keep in mind" information that you haven't
posted previously in the thread...

Your additional information just requires revising the macro a bit.
While there are myriad ways to do it, here's one:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Const sInputCells = "G7,I7,G13,I13,G14,I14,G33,I33"
Dim dFactor As Double
With Target
If .Count 1 Then Exit Sub
If Not Intersect(.Cells, Range(sInputCells)) Is Nothing Then
Select Case .Row
Case 7
dFactor = 50
Case 13
dFactor = 100
Case 14
dFactor = 300
Case 33
dFactor = 10
End Select
On Error GoTo ErrHandler
Application.EnableEvents = False
If .Column = 7 Then
.Offset(0, 2).Value = .Value / dFactor
ElseIf .Column = 9 Then
.Offset(0, -2).Value = .Value * dFactor
End If
End If
End With
ErrHandler:
Application.EnableEvents = True
End Sub

Of course, this assumes that there isn't additional information that
would require further modification.

Give up on SelectionChange - it will never do what you're asking for.

In article ,
monir wrote:

While I'm testing your event code, please keep in mind that there are similar
input pairs in G and I columns at different rows, each pair is related by a
different factor. For Example:
..........cells G7 and I7..........factor 50.
..........cells G13 and I13.......factor 100.
..........cells G14 and I14.......factor 300.
..........cells G33 and I33 ......factor 10.

Only those cells on the w/s should be affected by the Change or the
SelectionChange event.

Changing or selecting other cells on the sheet shouldn't be impacted by the
event.