title: prime number in vba excel 2003
body: <p>I'm analyzing a code from the website and I tried it on my side as well but seems it doesn't work. Could you please tell me why? would greatly appreciate your help. </p>
  
  <p>Thanks</p>
  
  <pre><code>Private Sub CommandButton1_Click()
      Dim N, D As Single
      Dim tag As String
  
      N = Cells(2, 2)
      Select Case N
          Case Is &lt; 2
              MsgBox "It is not a prime number"
          Case Is = 2
              MsgBox "It is a prime number"
          Case Is &gt; 2
              D = 2
              Do
                  If N / D = Int(N / D) Then
                      MsgBox "It is not a prime number"
                      tag = "Not Prime"
                      Exit Do
                  End If
                  D = D + 1
              Loop While D &lt;= N - 1
              If tag &lt;&gt; "Not Prime" Then
                  MsgBox "It is a prime number"
              End If
      End Select
  End Sub
  </code></pre>