Nachdem ich schon für die simplen Problem Hilfe brauche bin ich hierbei erst recht eure Hilfe.
Aus der Rechere habe ich kürzliche folgenden Code zum Export in eine txt-Datei kopiert. Er funktioniert einwandfrei. Nun habe ich aber drei Spalten verborgen die ich nicht exportieren will(A:A;G:G;K:K). Ist das überhaupt möglich? Und wenn ja, wie muss der Code dann aussehen?
Sub export7()
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
iRow = ActiveSheet.UsedRange.Rows.Count
iCol = ActiveSheet.UsedRange.Columns.Count
strSep = 9
If strSep = "" Then Exit Sub
If strSep = "9" Then
strSep = Chr(9)
Else
strSep = Left(Trim(strSep), 1)
End If
DateiName:
strDat = InputBox("Dateiname?", "DateiName", ThisWorkbook.Path & "\SPRUNGM____1148___" & Format(Now, "YYYYMMDDHHMMSS") & ".txt")
If strDat = "" Then Exit Sub
If InStr(strDat, ":\") = 0 Then
strDat = ThisWorkbook.Path & "\" & strDat
End If
If Dir(strDat) <> "" Then
strMldg = MsgBox("Datei bereits vorhanden. Überschreiben?", vbYesNo)
If strMldg = vbNo Then GoTo DateiName
End If
On Error GoTo DateiFehler
Open strDat For Output As #1
For iR = 1 To iRow
strTxt = ""
For iC = 1 To iCol
strTxt = strTxt & Cells(iR, iC) & strSep
Next iC
strTxt = Left(strTxt, Len(strTxt) - 1)
If Trim(Replace(strTxt, strSep, "")) > "" Then Print #1, strTxt
'Print #1, strTxt'
Next iR
Close #1
MsgBox ("Die Datei " & strDat & " wurde angelegt.")
Exit Sub
DateiFehler:
MsgBox ("Fehler in Dateinamen!")
Resume DateiName
End Sub
Bin dankbar für Vorschläge
Gruss bully