Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. Sub WriteTextFile()
  2. Dim FilePath As String
  3. Dim CellData As String
  4. Dim LastCol As Long
  5. Dim LastRow As Long
  6.  
  7. LastCol = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Column
  8. LastRow = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row
  9. CellData = ""
  10.  
  11. FilePath = Application.DefaultFilePath & "euth.csv"
  12.  
  13. Open FilePath For Output As #2
  14.  
  15. For i = 1 To LastRow
  16. For j = 1 To LastCol
  17.  
  18. If j = LastCol Then
  19. CellData = CellData + TrimtActiveCell(i, j).Value)
  20. Else
  21. CellData = CellData + TrimtActiveCell(i, j).Value) + ","
  22. End If
  23.  
  24. Next j
  25.  
  26. Write #2, CellData
  27. CellData = ""
  28. Next i
  29.  
  30. Close #2
  31.  
  32. MsgBox ("Done")
  33. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement