vba code for cutoff time code example

Example: vba code for cutoff time

Option Explicit

Sub stripTime()
    Dim i As Integer
    With Worksheets("Sheet1")
        'check to see if A1 is a date or a column text label
        i = Abs(Not IsDate(.Cells(1, 1).Value))
        With .Range(.Cells(1 + i, "A"), .Cells(.Rows.Count, "A").End(xlUp))
            .TextToColumns Destination:=.Cells(1, "C"), DataType:=xlFixedWidth, _
                           FieldInfo:=Array(Array(0, xlDMYFormat), Array(10, xlSkipColumn))
            'optionally assign a custom number format
            .Offset(0, 2).NumberFormat = "[color10]dd-mmm-yyyy_)"
            'optionally autofit the column width
            .Offset(0, 2).EntireColumn.AutoFit
        End With
    End With
End Sub

Tags:

Vb Example