title: VBA If Then statement to do stuff or end sub
body: <p>I have trouble doing a simple code.  I want to add If Then statement, if the condition is met (a cell value is not 1 or 7), then do a block of codes, otherwise end the sub.  The block of codes include login to a website and 2 For Next loops.  Basically the macro is to run during weekdays and not run if it's Saturday or Sunday. Appreciate your help.</p>
  
  <p>Here's a test code:</p>
  
  <pre><code>Sub test()
  
  Dim i As Integer
  
  'If cell E1 has a value of neither 1 or 7, Do stuff, otherwise End the Sub
  
  If Cells(5, 1) &lt;&gt; 1 Or Cells(5, 1) &lt;&gt; 7 Then
  
      'Do stuff includes login and perform 2 For Next loops in my real code 
      For i = 1 To 3
          Cells(i, 1).Value = Cells(i, 1).Value * 2
      Next
  
  End If
  
  End Sub
  </code></pre>