Double Line Delete

From IARC 207 Wiki
Jump to navigation Jump to search

Use this Macro to delete duplicate lines from the online shand data (off the WERC website). This data appears sometimes do to hiccups in the syncing stuff. So, if you run this macro here you'll delete the incomplete first line of data and keep just the complete second line.

See Bob for questions.

Sub deleter()
'
' deleter Macro
' Macro recorded 7/30/2008 by
' 
' 
   Dim row As Long
   Dim nextrow As Long
   Dim curday As Double
   Dim curtime As Double
   Dim curdt As Double
   Dim nextday As Double
   Dim nexttime As Double
   Dim nextdt As Double
   Dim worksheetz As Integer
   Dim daycol As Integer
   Dim timecol As Integer
   worksheetz = 2
   row = 4
   daycol = 6
   timecol = 7
   curtime = Worksheets(worksheetz).Cells(row, timecol).Value
   curday = Worksheets(worksheetz).Cells(row, daycol).Value
   curdt = curday + curtime / 2400
   row = row + 1
   Do While Worksheets(worksheetz).Cells(row, daycol).Value <> ""
     nexttime = Worksheets(worksheetz).Cells(row, timecol).Value
     nextday = Worksheets(worksheetz).Cells(row, daycol).Value
     nextdt = nextday + nexttime / 2400
     If nextdt = curdt Then
           Rows(CStr(row - 1) & ":" & CStr(row - 1)).Select
           Selection.Delete Shift:=xlUp
     Else
       curdt = nextdt
       row = row + 1
     End If
   Loop   
End Sub