das untenstehende Makro funktioniert bestens.
Aber wie kann ich vermeiden, dass Excel ausgeblendete Zeilen (mit Daten >> Filtern >> erstellt) nicht in die CSV-Datei schreibt.
Jetzt schon herzlichen Dank für eine evtl. Hilfe-Stellung
Markus
Option Explicit
Sub Export_fuer_MDSOFT()
Dim strSep As String, strDat As String, _
iCol As Byte, iRow As Integer, _
iR As Integer, iC As Byte, strTxt As String, _
strMldg As String, strDel As String, strdateiname As String
iRow = ActiveSheet.UsedRange.Rows.Count
iCol = Cells(1, Columns.Count).End(xlToLeft).Column ' nicht UsedRange
' wenn ohne Gänsefüße: strDel = ""
' strDel = Chr(34)
strDel = ""
strSep = ";"
If strSep = "" Then Exit Sub
If strSep = "9" Then
strSep = Chr(9)
Else
strSep = Left(Trim(strSep), 1)
End If
strdateiname = Replace(ActiveWorkbook.Name, ".xlsm", "")
' MsgBox strdateiname
DateiName:
' strDat = InputBox("Dateiname?", "DateiName", ThisWorkbook.Path & "\")
strDat = ThisWorkbook.Path & "\" & strdateiname & ".csv"
If strDat = "" Then Exit Sub
If InStr(strDat, ":\") = 0 Then strDat = ThisWorkbook.Path & "\" & strDat
If Dir(strDat) "" Then
Kill strDat
End If
On Error GoTo DateiFehler
Open strDat For Output As #1
For iR = 2 To iRow ' ab 2 - ohne Überschrift
strTxt = strDel & Cells(iR, 1) & strDel
For iC = 2 To iCol
strTxt = strTxt & strSep & strDel & Cells(iR, iC) & strDel
Next iC
Print #1, strTxt
Next iR
Close #1
MsgBox ("Die Datei " & strDat & " wurde angelegt.")
Exit Sub
DateiFehler:
MsgBox ("Fehler in Dateinamen!")
Resume DateiName
End Sub