title: VBA Nested IF statement
body: <p>I want to show a message box when a specific cell has a particular value in it. I have done this with the following code;</p>
  
  <pre><code>If Range("P8") = "Y" Then
          MsgBox "Message here"
  End If
  </code></pre>
  
  <p>This is within the <code>Worksheet_Change</code> sub so shows the message box everytime another cell value changes. I have tried to get around this by adding a boolean variable, set to true when the messagebox has been shown the first time;</p>
  
  <pre><code>If Range("P8") = "Y" Then
      If messageshown = False Then
          messageshown = True
          MsgBox "Message here"
      Else
      End If
  Else
  End If
  </code></pre>
  
  <p>However the message box still shows every time I change a cell in the worksheet. I have a feeling it';s to do with the way I have written the nested if statement but have tried various different ways and orders of where I place <code>else</code> and <code>end if</code> but to no avail.</p>