LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Worksheet_Change Event "Circular Reference"

Hi,

I have an interesting problem. I have a worksheet where
I want to be able to make the action of changing the
value of cell A1, cause the value of B1 display double
the value of A1. If I type a value in B1 I want A1 to
display half the value of B1 (Actually the calculation is
much more complicated, but just for testing purposes any
relational calculation will do.) When I use the
Worksheet_Change event, it captures the value changes in
one cell and runs the calculation, but that then changes
the value of the adjacent cell which then runs the code
again, etc. I have found that after approx. 220
iterations it finally stops, but this can cause loads of
other problems for me.

To put it simply, how can I tell the worksheet_change
event not to fire if code run from that event causes
other cells to change. Here is a sample of my code below:

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)

Dim v As Variant
Static x As Long

x = x + 1

Select Case Target.Column
Case 1
With Target
.Font.Bold = True
.Offset(0, 1).Font.Bold = False
.Offset(0, 1) = Target * 2
End With
Case 2
v = Application.Caller
Debug.Print v
With Target
.Font.Bold = True
.Offset(0, -1).Font.Bold = False
.Offset(0, -1) = Target / 2
End With
End Select

Application.StatusBar = x

End Sub

Please note that the x variable is used to check how many
times this event runs before it stops and I have no idea
on how to use the Caller property. I thought that maybe
it could be used to see if the event called itself and
therefore be used to tell it to stop.

Please help...this is driving me nuts.
Many thanks
Vyyk
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
change cell event using circular reference - not VBA! Dan Excel Worksheet Functions 3 June 17th 08 03:26 PM
change cell event using circular reference Dan Excel Worksheet Functions 3 June 17th 08 10:32 AM
Circular reference error when trying to keep a "running Tally" CrisT Excel Discussion (Misc queries) 0 June 26th 07 06:00 PM
How do I make a "Worksheet_Change event" to show any changes to cells? [email protected] Excel Worksheet Functions 2 April 26th 06 06:28 PM


All times are GMT +1. The time now is 12:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"