Advertisement
Guest User

Untitled

a guest
Apr 25th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. Sub ImportPickTask()
  2. Dim fName As String
  3. Dim strDataRange As Range
  4.  
  5.  
  6. Sheets("PicktaskImport").UsedRange.ClearContents
  7.  
  8. fName = Application.GetOpenFilename("Text Files (*.txt), *.txt")
  9. If fName = "False" Then Exit Sub
  10.  
  11. With ActiveSheet.QueryTables.Add(Connection:="TEXT;" & fName, _
  12. Destination:=Sheets("PicktaskImport").Range("$d$1"))
  13. .Name = "sample"
  14. .FieldNames = True
  15. .RowNumbers = False
  16. .FillAdjacentFormulas = False
  17. .PreserveFormatting = True
  18. .RefreshOnFileOpen = False
  19. .RefreshStyle = xlInsertDeleteCells
  20. .SavePassword = False
  21. .SaveData = True
  22. .AdjustColumnWidth = True
  23. .RefreshPeriod = 0
  24. .TextFilePromptOnRefresh = False
  25. .TextFilePlatform = 437
  26. .TextFileStartRow = 1
  27. .TextFileParseType = xlDelimited
  28. .TextFileTextQualifier = xlTextQualifierNone
  29. .TextFileConsecutiveDelimiter = True
  30. .TextFileTabDelimiter = False
  31. .TextFileSemicolonDelimiter = False
  32. .TextFileCommaDelimiter = True
  33. .TextFileSpaceDelimiter = False
  34. .TextFileOtherDelimiter = "" & Chr(10) & ""
  35. .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, _
  36. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _
  37. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _
  38. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
  39. .TextFileTrailingMinusNumbers = True
  40. .Refresh BackgroundQuery:=False
  41. Range("D2:H5000").Sort Key1:=Range("D2"), order1:=xlAscending, Key2:=Range("E2"), order2:=xlAscending
  42.  
  43. Range("D1").Font.Color = vbRed
  44. Range("e1").Font.Color = vbRed
  45. Range("f1").Font.Color = vbRed
  46. Range("g1").Font.Color = vbRed
  47. Range("h1").Font.Color = vbRed
  48. Range("E2:E5000").Font.Color = vbBlack
  49. Range("D2:D5000").NumberFormat = "0"
  50. Range("E2:E5000").NumberFormat = "General"
  51. Range("F2:F5000").NumberFormat = "00000000000000000000"
  52. Range("G2:G5000").NumberFormat = "000000"
  53. Range("H2:H5000").NumberFormat = "0"
  54. Range("K2:K5000").NumberFormat = "000000000000"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement