Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. Sub FormatACTrade(strFilePath As String) 'I'm running this from another _
  2. sub that exports the tables to excel, I know functions are needed for _
  3. an output but this is a private variable that I'm using within a modle_
  4. so should be ok??
  5.  
  6. On Error GoTo ErrorHandler
  7.  
  8. Set objExcel = CreateObject("Excel.Application")
  9. objExcel.Visible = False
  10. objExcel.DisplayAlerts = False
  11. Set objFso = CreateObject("Scripting.FileSystemObject")
  12. Set objFolder = objFso.GetFolder(strFilePath)
  13.  
  14. If objFso.GetExtensionName(objFile.Path) = "xlsx" Then
  15. Set objWorkbook = objExcel.Workbooks.Open(objFile.Path)
  16. For Each sh In objWorkbook.Worksheets
  17. If sh.UsedRange.Address <> "$A$1" Or sh.Range("A1") <> "" Then
  18. With sh
  19. [Do stuff]
  20. End With
  21. End If
  22. Next
  23. objWorkbook.Close True
  24. End If
  25. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement