Private Sub Auto_Open()
Call WorktimeReport
End Sub
Sub WorktimeReport()
Application.ScreenUpdating = False
Sheets("Sheet1").Select
Cells.Select
Selection.ClearContents
With ActiveSheet.QueryTables.Add(Connection:="TEXT;D:\transfer.Asc", _
Destination:=Range("A4"))
.Name = "transfer"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 720
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = True
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = True
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _
1, 1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 3
Columns("M:AD").Select
Selection.Delete Shift:=xlToLeft
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
ActiveWindow.SmallScroll Down:=-12
Rows("3:3").Select
Selection.Font.Bold = True
Range("B3").Select
ActiveCell.FormulaR1C1 = "Date "
Range("C3").Select
ActiveCell.FormulaR1C1 = "Employee No"
Columns("C:C").Select
Selection.ColumnWidth = 11.57
Range("D3").Select
Columns("C:C").ColumnWidth = 12.29
Range("D3").Select
ActiveCell.FormulaR1C1 = "Operation "
Columns("E:E").Select
Columns("D:D").ColumnWidth = 8.29
Columns("D:D").ColumnWidth = 9
Range("E3").Select
ActiveCell.FormulaR1C1 = "Time"
Columns("F:F").Select
Selection.Delete Shift:=xlToLeft
ActiveWindow.SmallScroll Down:=-18
Range("H3").Select
ActiveCell.FormulaR1C1 = "Job Order"
Range("H3").Select
Columns("H:H").ColumnWidth = 9.14
ActiveWindow.SmallScroll Down:=-18
Columns("I:J").Select
Selection.Delete Shift:=xlToLeft
Columns("F:G").Select
Columns("F:G").EntireColumn.AutoFit
ActiveWindow.SmallScroll Down:=15
Selection.Delete Shift:=xlToLeft
Columns("G:G").Select
Selection.Delete Shift:=xlToLeft
Range("G3").Select
ActiveCell.FormulaR1C1 = "Regular"
Range("H3").Select
ActiveCell.FormulaR1C1 = "Overtime"
Range("E1").Select
ActiveCell.FormulaR1C1 = "Soft Pro Daily Report"
Range("G1").Select
ActiveCell.FormulaR1C1 = ""
Range("D1").Select
Columns("E:E").ColumnWidth = 17.14
Range("E1").Select
ActiveCell.FormulaR1C1 = "Soft Pro Daily Report"
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Columns("E:E").ColumnWidth = 17.86
Range("E3").Select
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("E1").Select
ActiveCell.FormulaR1C1 = "Soft Pro Daily Report"
Rows("1:1").Select
Selection.Font.Bold = True
With Selection.Font
.Name = "Arial"
.Size = 14
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Rows("1:1").Select
With Selection.Font
.Name = "Arial"
.Size = 12
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("G4").Select
ActiveCell.FormulaR1C1 = _
"=IF(R[40440]C[-2]<=TIMEVALUE(""5:30:00 pm""),""1"",""0"")"
Range("H4").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-3]>TIMEVALUE(""5:30:00 pm""),""1"",""0"")"
Range("G4").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-2]<=TIMEVALUE(""5:30:00 pm""),""1"",""0"")"
Range("H4").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-3]>TIMEVALUE(""5:30:00 pm""),""1"",""0"")"
Range("G4").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-2]<=TIMEVALUE(""5:30:00 pm""),""1"",""0"")"
Range("G2").Select
Columns("G:G").ColumnWidth = 26.71
Range("G4").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-2]<=TIMEVALUE(""5:30:00 pm""),""1"",""0"")"
Range("G1").Select
Columns("G:G").ColumnWidth = 34.29
Range("G4").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-2]<=TIMEVALUE(""5:30:00 pm""),""1"",""0"")"
Range("G1").Select
Columns("G:G").ColumnWidth = 39.14
Range("G4").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-2]<=TIMEVALUE(""5:30:00 pm""),""1"",""0"")"
Selection.AutoFill Destination:=Range("G4:G45919")
Range("G4:G45919").Select
Range("G5").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-2]<=TIMEVALUE(""5:30:00 pm""),""1"",""0"")"
Range("G8").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-2]<=TIMEVALUE(""5:30:00 pm""),""1"",""0"")"
Range("G7").Select
Columns("G:G").ColumnWidth = 9.57
Columns("G:G").Select
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("H4").Select
Columns("H:H").ColumnWidth = 28
Range("I1").Select
Columns("H:H").ColumnWidth = 33.57
Columns("H:H").ColumnWidth = 38.71
Range("H4").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-3]>TIMEVALUE(""5:30:00 pm""),""1"",""0"")"
Range("H4").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-3]>TIMEVALUE(""5:30:00 pm""),""1"",""0"")"
Selection.AutoFill Destination:=Range("H4:H45919")
Range("H4:H45919").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-3]>TIMEVALUE(""5:30:00 pm""),""1"",""0"")"
Range("H3").Select
ActiveCell.FormulaR1C1 = "Overtime"
Range("H1").Select
Columns("H:H").ColumnWidth = 13.57
Columns("H:H").ColumnWidth = 10.29
Range("H3").Select
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 1
Range("B3").Select
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Range("E2").Select
Application.ScreenUpdating = True
Range("A1").Select
End Sub
thanks in advance
Bookmarks