AW: Textdatei mit VBA erzeugen
19.01.2011 11:22:18
Kawensmann
Hallo,
es mag einfachere Möglichkeiten geben, aber so sollte es gehen:
Sub ExportAsText()
Dim intFileNumber As Integer
Dim strExportFile As String
Dim wks As Worksheet
Dim strFile As String
Dim lngRow As Long
Dim intColumn As Integer
Dim strTMP As String
strExportFile = "d:\Export.txt"
intFileNumber = FreeFile
Set wks = ThisWorkbook.Worksheets(1)
Open strExportFile For Output As intFileNumber
With wks
For lngRow = 1 To .UsedRange.Rows.Count
For intColumn = 1 To .UsedRange.Columns.Count
strTMP = strTMP & CStr(.Cells(lngRow, intColumn).Value) & ";"
strFile = strFile & strTMP
strTMP = ""
Next
strFile = strFile & vbCrLf
Next
End With
Print #intFileNumber, Left(strFile, Len(strFile) - 1);
Close #intFileNumber
End Sub
Gruß
Kawensmann