SHARE
TWEET

Untitled

a guest Jun 18th, 2019 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top