Guest User

Untitled

a guest
Dec 11th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. Sub ImportAppReport()
  2. Dim fName As FileDialog, result As Integer, it As Variant, LastRow As Long
  3. Dim myVal1 As Variant
  4. Dim myValn As String
  5. Dim Cml As Worksheet
  6. Dim Aud As Worksheet
  7. Set Aud = Worksheets("CURRENT")
  8. Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = "OLD"
  9. Set Cml = Worksheets("OLD")
  10.  
  11. 'find folder by userinput date'
  12. myVal1 = InputBox("Please enter today's date in mm-dd format")
  13. myValn = Replace(myVal1, "-", "")
  14.  
  15. fName = Application.FileDialog(msoFileDialogOpen)
  16. If fName = "False" Then Exit Sub
  17.  
  18. LastRow = Range("A" & Rows.Count).End(xlUp).Row + 1
  19.  
  20. With ActiveSheet.QueryTables.Add(Connection:="\olscmesf003gcm_emeaTCU_REPORTSAPPSReportsRegionalPointsec for PC Web RH2017" & myValn, _
  21. Destination:=Range("A" & LastRow))
  22. .Name = "sample"
  23. .FieldNames = True
  24. .RowNumbers = False
  25. .FillAdjacentFormulas = False
  26. .PreserveFormatting = True
  27. .RefreshOnFileOpen = False
  28. .RefreshStyle = xlInsertDeleteCells
  29. .SavePassword = False
  30. .SaveData = True
  31. .AdjustColumnWidth = True
  32. .RefreshPeriod = 0
  33. .TextFilePromptOnRefresh = False
  34. .TextFilePlatform = 437
  35. .TextFileStartRow = 1
  36. .TextFileParseType = xlDelimited
  37. .TextFileTextQualifier = xlTextQualifierNone
  38. .TextFileConsecutiveDelimiter = True
  39. .TextFileTabDelimiter = False
  40. .TextFileSemicolonDelimiter = False
  41. .TextFileCommaDelimiter = True
  42. .TextFileSpaceDelimiter = False
  43. .TextFileOtherDelimiter = "" & Chr(10) & ""
  44. .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, _
  45. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _
  46. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _
  47. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
  48. .TextFileTrailingMinusNumbers = True
  49. .Refresh BackgroundQuery:=False
  50. End With
  51. End Sub
Add Comment
Please, Sign In to add comment