title: worksheet_change function causing loop
body: <p>Firstly, as you may notice from below, my VBA skills are very limited!</p>
  
  <p>I am creating a spreadsheet and i'm trying to include some sanity checking.  Basically, if cell G69 is greater than zero then it means that an item has been bought, and therefore cell G68 (which defines the type of item that has been bought) cannot equal none, it must be a value (I force it to be 'eggs').  if G69 is not greater than zero then nothing's been bought and so G68 should be forced to 'none'.</p>
  
  <p>Similarly, if cell G68 is set to 'none', then nothing's being bought so G69 should be forced to zero.</p>
  
  <p>the code i've cobbled together for this is below:</p>
  
  <hr>
  
  <pre><code>Private Sub Worksheet_Change(ByVal Target As Range)
  
  If Target.Address = "$G$69" Then
  
   If Range("$G$69").Value &gt; 0 Then
  
     Range("$g$68").Value = "Eggs"
  
   Else: Range("$g$68").Value = "None"
  
  End If
  
  End If
  
  If Target.Address = "$G$68" Then
  
   If Range("$G$68").Value = "None" Then
  
    Range("$g$69").Value = 0
  
   End If
  
  End If
  
  End Sub
  </code></pre>
  
  <hr>
  
  <p>I keep getting errors when running the macro, and I think it's because it creates a loop - I change the value of G69, as a result it changes the value of G68, which in turn triggers the if routine for that cell changing and therefore it tries to set G69 to a value, and so on...</p>
  
  <p>Can anyone explain what i'm doing wrong?  I suspect it's quite simple to resolve and related to my clumsy coding! :)</p>
  
  <p>hope that makes sense!  Many thanks..</p>
  
  <p>Pat </p>