Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub ImportPickTask()
- Dim fName As String
- Dim strDataRange As Range
- Sheets("PicktaskImport").UsedRange.ClearContents
- fName = Application.GetOpenFilename("Text Files (*.txt), *.txt")
- If fName = "False" Then Exit Sub
- With ActiveSheet.QueryTables.Add(Connection:="TEXT;" & fName, _
- Destination:=Sheets("PicktaskImport").Range("$d$1"))
- .Name = "sample"
- .FieldNames = True
- .RowNumbers = False
- .FillAdjacentFormulas = False
- .PreserveFormatting = True
- .RefreshOnFileOpen = False
- .RefreshStyle = xlInsertDeleteCells
- .SavePassword = False
- .SaveData = True
- .AdjustColumnWidth = True
- .RefreshPeriod = 0
- .TextFilePromptOnRefresh = False
- .TextFilePlatform = 437
- .TextFileStartRow = 1
- .TextFileParseType = xlDelimited
- .TextFileTextQualifier = xlTextQualifierNone
- .TextFileConsecutiveDelimiter = True
- .TextFileTabDelimiter = False
- .TextFileSemicolonDelimiter = False
- .TextFileCommaDelimiter = True
- .TextFileSpaceDelimiter = False
- .TextFileOtherDelimiter = "" & Chr(10) & ""
- .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, 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
- Range("D2:H5000").Sort Key1:=Range("D2"), order1:=xlAscending, Key2:=Range("E2"), order2:=xlAscending
- Range("D1").Font.Color = vbRed
- Range("e1").Font.Color = vbRed
- Range("f1").Font.Color = vbRed
- Range("g1").Font.Color = vbRed
- Range("h1").Font.Color = vbRed
- Range("E2:E5000").Font.Color = vbBlack
- Range("D2:D5000").NumberFormat = "0"
- Range("E2:E5000").NumberFormat = "General"
- Range("F2:F5000").NumberFormat = "00000000000000000000"
- Range("G2:G5000").NumberFormat = "000000"
- Range("H2:H5000").NumberFormat = "0"
- Range("K2:K5000").NumberFormat = "000000000000"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement