title: VBA: For-Loop should not stop when encountering an error, it should jump to the next block
body: <p>I need to modify a for-loop, so that it skips to the next iteration when it does not find an object. Here is a snippet:</p>
  
  <pre><code>For j = 0 To i - 1
  
    Proj = Cells(3 + j, 2).Value
  
    ResClass = Cells(3 + j, 3).Value
  
      Set project = resq.Projects.Item(Proj)
      Set class = project.ReservingClasses(ResClass)
  
      Set CFP = class.Vectors("Cashflow DFM JM").Method
      Set CFPvol5 = class.Vectors("Cashflow DFM JM vol5").Method
      Set CFPTr = class.Vectors("Cashflow DFM JM Tr").Method
  
      orig = project.OriginCount 
  
  For k = 1 To orig
  
              Cells(20 - 3, 4) = "DFM JM"
              Cells(20 - 3, 4).Font.Bold = True
              Cells(20 + k, col) = CFP.CashFlowPeriodLabel(k) - orig
              Cells(20 - 2, col) = Cells(3 + j, 1).Value
              Cells(20 - 2, col).Font.Bold = True
              Cells(20 - 1, col + 1) = CFP.CashFlowPeriodLabel(1)
              Cells(20 + k, col + 1) = Round(CFP.DiscountedCashflows(k, 1), 0)
              Cells(20 - 1, col + 2) = CFP.CashFlowPeriodLabel(2)
              Cells(20 + k, col + 2) = Round(CFP.DiscountedCashflows(k, 2), 0)
  
              Cells(59 - 3, 4) = "DFM Paid vol5"
              Cells(59 - 3, 4).Font.Bold = True
              Cells(59 + k, col) = CFPvol5.CashFlowPeriodLabel(k) - orig
              Cells(59 - 2, col) = Cells(3 + j, 1).Value
              Cells(59 - 2, col).Font.Bold = True
              Cells(59 - 1, col + 1) = CFPvol5.CashFlowPeriodLabel(1)
              Cells(59 + k, col + 1) = Round(CFPvol5.DiscountedCashflows(k, 1), 0)
              Cells(59 - 1, col + 2) = CFPvol5.CashFlowPeriodLabel(2)
              Cells(59 + k, col + 2) = Round(CFPvol5.DiscountedCashflows(k, 2), 0)
  
              Cells(98 - 3, 4) = "DFM JM Tr"
              Cells(98 - 3, 4).Font.Bold = True
              Cells(98 + k, col) = CFPTr.CashFlowPeriodLabel(k) - orig
              Cells(98 - 2, col) = Cells(3 + j, 1).Value
              Cells(98 - 2, col).Font.Bold = True
              Cells(98 - 1, col + 1) = CFPTr.CashFlowPeriodLabel(1)
              Cells(98 + k, col + 1) = Round(CFPTr.DiscountedCashflows(k, 1), 0)
              Cells(98 - 1, col + 2) = CFPTr.CashFlowPeriodLabel(2)
              Cells(98 + k, col + 2) = Round(CFPTr.DiscountedCashflows(k, 2), 0)
  
  Next k
      col = col + 4
  
  
  Next
  </code></pre>
  
  <p>If for a certain j in the first for-loop there is no CFPvol5 in the second for-loop, then the procedure stops with an error. I want the procedure to continue with the next block, in this case with CFPTr. Is this possible? And if yes, how?</p>
  
  <p>Thank you very much for your help!</p>