title: Validating various conditions
body: <p>I have put together some code that will go through some data in a sheet named 'test' to check the following:</p>
  
  <p>(1) confirm if there is an error in column 2.
  (2) confirm if there is a false in column 3.
  (3) confirm if there is a blank in the range defined (from A1 to last row in C).</p>
  
  <p>It will then give you a message box telling you what the issue is. </p>
  
  <p>Code is:</p>
  
  <pre><code>Sub check()
  
  Dim y As Long, i As Long, LastRow As Long
  Dim chkAA As Boolean, chkTEP As Boolean, chkNULL As Boolean
  Dim row As Range, rng As Range, cell As Range
  
  LastRow = Sheets("test").Cells(Rows.Count, "A").End(xlUp).row
  Set rng = Sheets("Test").Range("A1:C" &amp; LastRow)
  Dim output As Integer
  
  chkAA = True
  chkTEP = True
  chkNULL = True
  
  For y = 1 To Rows.Count
       If IsError(Sheets("Test").Cells(y, 2).Value) Then
            chkAA = False
            Exit For
       End If
  Next y
  
  For i = 1 To Rows.Count
       If Sheets(“Test”).Cells(i, 3).Value = "False" Then
            chkTEP = False
            Exit For
       End If
  Next i
  
  For Each row In rng.Rows
    For Each cell In row.Cells
      If IsEmpty(cell.Value) Then
        chkNULL = False
      End If
    Next cell
  Next row
  
  
  
  If chkAA = True And chkTEP = True And chkNULL = True Then
  output = MsgBox("Validation complete", vbInformation, "Validation")
  ElseIf chkAA = False And chkTEP = True And chkNULL = True Then
  output = MsgBox("Double check your AA numbers", vbCritical, "Validation")
  ElseIf chkAA = True And chkTEP = False And chkNULL = True Then
  output = MsgBox("Double check your TEP combination", vbCritical, "Validation")
  ElseIf chkAA = True And chkTEP = True And chkNULL = False Then
  output = MsgBox("There is a blank cell", vbCritical, "Validation")
  ElseIf chkAA = False And chkTEP = False And chkNULL = True Then
  output = MsgBox("Double check your AA numbers and TEP combination", vbCritical, "Validation")
  ElseIf chkAA = False And chkTEP = True And chkNULL = False Then
  output = MsgBox("Double check your AA numbers and do not leave blanks", vbCritical, "Validation")
  ElseIf chkAA = True And chkTEP = False And chkNULL = False Then
  output = MsgBox("Double check your TEP combination and do not leave blanks", vbCritical, "Validation")
  Else: chkAA = False And chkTEP = False And chkNULL = False:
  output = MsgBox("Please make sure spreadhseet is filled correctly", vbCritical, "Validation")
  End If
  
  End Sub
  </code></pre>
  
  <p>It gives me an error that it is out of range. </p>
  
  <p>Can you please advise me where I am going wrong?</p>
  
  <p>Thanks</p>