title: Bad data selection using VBScript , on date field values
body: <p>I have a sheet which contains data as below:</p>
  
  <p><img src="https://i.stack.imgur.com/tcPSC.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/eJo1w.png" alt="enter image description here"></p>
  
  <p>Now the Excel is having 36 total tasks,Each tasks has 4 columns with in it. first task .i.e Task1 name will always be started from the L column. 36 tasks has been described 144 columns. Now we need to go through row-wise and need to check if TNStart Start date &lt; T(N+1) Start date.then that row would be selected as bad row. In brief when the task# number will be increased from 1 to 36,the start date should be respective needs to be in increasing order.If that fails anytime,row should be marked as bad data.</p>
  
  <p>can you guys help me here to do this in good fashionable way?</p>
  
  <pre><code>Option Explicit
  
  Dim objExcel1
  Dim strPathExcel1
  Dim objSheet1,objSheet2
  Dim IntRow1,IntRow2
  Dim ColStart
  
  Set objExcel1 = CreateObject("Excel.Application")'Object for Condition Dump
  
  strPathExcel1 = "D:\AravoVB\Copy of Original   Scripts\CopyofGEWingtoWing_latest_dump_21112012.xls"
  objExcel1.Workbooks.Open strPathExcel1
  Set objSheet1 = objExcel1.ActiveWorkbook.Worksheets(1)
  Set objSheet2 = objExcel1.ActiveWorkbook.Worksheets("Bad Data")
  
  objExcel1.ScreenUpdating = False
  objExcel1.Calculation = -4135  'xlCalculationManual
  
  IntRow2=2
  IntRow1=4
  Do Until IntRow1 &gt; objSheet1.UsedRange.Rows.Count
      ColStart = objExcel1.Application.WorksheetFunction.Match("Parent Business Process ID", objSheet1.Rows(3), 0) + 1 
      Do Until ColStart &gt; objSheet1.UsedRange.Columns.Count And objSheet1.Cells(IntRow1,ColStart) = ""
          If objSheet1.Cells(IntRow1,ColStart + 1) &gt; objSheet1.Cells(IntRow1,ColStart + 5) and objsheet1.cells(IntRow,ColStart + 5) &lt;&gt; "" Then
              objSheet1.Range(objSheet1.Cells(IntRow1,1),objSheet1.Cells(IntRow1,objSheet1.UsedRange.Columns.Count)).Copy
              objSheet2.Range(objSheet2.Cells(IntRow2,1),objSheet2.Cells(IntRow2,objSheet1.UsedRange.Columns.Count)).PasteSpecial
              IntRow2=IntRow2+1
              Exit Do
          End If
          ColStart=ColStart+4
      Loop
  
      IntRow1=IntRow1+1
  Loop
  
  objExcel1.ScreenUpdating = True
  objExcel1.Calculation = -4105   'xlCalculationAutomatic
  </code></pre>
  
  <p><strong>Bad Performance</strong></p>
  
  <p><em>My sheet has 2000 rows and the bad data selection criterion is going on 144 columns.Now the output is coming after 25 mins.So it increasing the overall performance.Thus I am requesting you people to help me by making it more faster one.</em></p>
  
  <p><strong><em>Is it possible also when it is coping bad row to another sheet,also marked the bad columns in RED</em></strong></p>