Option Explicit
Sub ClearBlankRows_TextToColumns_Duplicates()
Dim LastRow As Long, LastCol As Long, FirstRow As Long, RowNo As Long
If Range("A1") = "" Then
FirstRow = Range("A1").End(xlDown).Row
If Range("A" & FirstRow) = "Tool starting." Then
Rows(1 & ":" & FirstRow).EntireRow.Delete
Else
Rows(1 & ":" & FirstRow - 1).EntireRow.Delete
End If
End If
If Not IsDate(Left(Range("A2"), 10)) Then
Range("A2").EntireRow.Delete
End If
Do
LastRow = Range("A" & Rows.Count).End(xlUp).Row
If Not IsDate(Left(Range("A" & LastRow), 10)) Then
Range("A" & LastRow).EntireRow.Delete
Else
Exit Do
End If
Loop
Range("A1:A" & LastRow).TextToColumns Destination:=Range("A1"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(11, 1), Array(22, 9), _
Array(25, 9), Array(28, 1), Array(42, 1), _
Array(56, 2), Array(69, 9), Array(91, 9), _
Array(115, 1), Array(120, 1), Array(129, 9)), _
TrailingMinusNumbers:=True
Columns("E:E").Insert Shift:=xlToRight
LastCol = Cells(1, Columns.Count).End(xlToLeft).Column
Range(Cells(1, 1), Cells(1, LastCol)).EntireColumn.AutoFit
Range("B1") = "TIME"
Application.ScreenUpdating = False
On Error GoTo ResetApplication
Range("E2").Resize(LastRow - 1, 1).Formula = "=LEFT(D2,7)"
Range("J2").Resize(LastRow - 1, 1).Formula = "=E2&F2&H2"
Range("K2").Resize(LastRow - 1, 1).Formula = "=COUNTIF($J2:$J" & LastRow - 1 & ",J2)"
Range("K2:K" & LastRow - 1).Copy
Range("K2:K" & LastRow - 1).PasteSpecial xlPasteValues
Range("$A$1:$K$" & LastRow).AutoFilter Field:=11, Criteria1:="1"
Rows("6:" & LastRow).Delete Shift:=xlUp
Range("$A$1:$K$11613").AutoFilter
Columns("J:K").Clear
ResetApplication:
Err.Clear
On Error GoTo 0
Application.ScreenUpdating = True
Range("A1").Select
End Sub
Bookmarks