Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
384to388
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
384to388
384to388
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

das komma soll weg

das komma soll weg
22.02.2004 21:16:27
sLy
hallo ich hab ein, ich glaub kleines problem vielleicht... und zwar hab ich mir hier vor kurzen mal nen VB script zusammen gebastelt wo man daten aus excel in eine txt datei speichern kann nun mein problem wenn ich das mache dann speichert er das auch aber er nimmt als trennzeichen ein komma dafür soll nun aber ein semikolon oder wie das geschrieben wird rein also dieses hier ";" ich hab das zwar schonmal gemacht er speichert das zwar so wie ich mir das vorstelle aber wenn er wieder in excel reinschreibt sagt er Fehler... kann mir einer helfen?? hier der Quellcode:

Sub ArtikelINtxt()
Dim rng As Range
Dim iRow As Integer, iCol As Integer, iFile As Integer
Dim sFile As String, sTxt As String
Set rng = Range("A1").CurrentRegion
sFile = ThisWorkbook.Path & "\" & "Artikeldaten.txt"
iFile = FreeFile
Open sFile For Output As iFile
For iRow = 1 To rng.Rows.Count
For iCol = 1 To rng.Columns.Count
sTxt = sTxt & Cells(iRow, iCol).Value & ","
Next iCol
sTxt = Left(sTxt, Len(sTxt) - 1)
Print #iFile, sTxt
sTxt = ""
Next iRow
Close iFile
rng.ClearContents
End Sub


Sub ArtikelOUTtxt()
Dim iRow As Integer, iFile As Integer
Dim sFile As String, sTxtA As String, sTxtB As String, sTxtC As String
sFile = ThisWorkbook.Path & "\" & "Artikeldaten.txt"
If Dir(sFile) = "" Then
MsgBox "Die Artikeldaten konnten nicht geladen werden!"
Exit Sub
End If
iFile = FreeFile
Open sFile For Input As iFile
Do Until EOF(iFile)
Input #iFile, sTxtA, sTxtB, sTxtC
iRow = iRow + 1
Cells(iRow, 1).Value = sTxtA
Cells(iRow, 2).Value = sTxtB
Cells(iRow, 3).Value = sTxtC
Loop
Close
End Sub

7
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: das komma soll weg
22.02.2004 21:38:30
Josef Ehrensberger
Hallo ?
Probier den Import mal mit diesm Code (Trennzeichen ";")


Sub ArtikelOUTtxt()
   Dim iRow As Integer, iCol As Integer
   Dim sFile As String, sTxt As String
   sFile = ThisWorkbook.Path & "\" & "Artikeldaten.txt"
   If Dir(sFile) = "" Then
      MsgBox "Die Artikeldaten konnten nicht geladen werden!"
      Exit Sub
   End If
   iRow = 1
   iCol = 1
   Open sFile For Input As #1
      Do Until EOF(1)
         Line Input #1, sTxt
         Do While InStr(sTxt, ";")
            Cells(iRow, iCol) = Left(sTxt, InStr(sTxt, ";") - 1)
            sTxt = Right(sTxt, Len(sTxt) - InStr(sTxt, ";"))
            iCol = iCol + 1
         Loop
         Cells(iRow, iCol) = sTxt
         iRow = iRow + 1
         iCol = 1
      Loop
   Close
End Sub

     Code eingefügt mit Syntaxhighlighter 2.5

Gruß Sepp
Ein kluger Mann macht nicht alle Fehler selbst.
Er lässt auch anderen eine Chance.

(Sir Winston Churchill)
Anzeige
AW: das komma soll weg
22.02.2004 21:51:35
sLy
Super besten dank...
AW: das komma soll weg
22.02.2004 22:08:57
sLy
Haut alles bestens hin - nur hab ich jetzt noch ein kleines Problem die letzte Zeile besteht aus Zahlen die nun aber als Text gespeichert werden.
Wie ändere ich das?
AW: das komma soll weg
22.02.2004 22:10:17
sLy
Spalte mein ich - nicht Zeile!
AW: das komma soll weg
22.02.2004 22:25:35
Josef Ehrensberger
Hallo,
der gleiche Code mit einer änderung.


Sub ArtikelOUTtxt()
   Dim iRow As Integer, iCol As Integer
   Dim sFile As String, sTxt As String
   sFile = ThisWorkbook.Path & "\" & "Artikeldaten.txt"
   If Dir(sFile) = "" Then
      MsgBox "Die Artikeldaten konnten nicht geladen werden!"
      Exit Sub
   End If
   iRow = 1
   iCol = 1
   Open sFile For Input As #1
      Do Until EOF(1)
         Line Input #1, sTxt
         Do While InStr(sTxt, ";")
            Cells(iRow, iCol) = Left(sTxt, InStr(sTxt, ";") - 1)
            If IsNumeric(Cells(iRow, iCol)) Then Cells(iRow, iCol) = Cells(iRow, iCol) * 1
            sTxt = Right(sTxt, Len(sTxt) - InStr(sTxt, ";"))
            iCol = iCol + 1
         Loop
         Cells(iRow, iCol) = sTxt
         If IsNumeric(Cells(iRow, iCol)) Then Cells(iRow, iCol) = Cells(iRow, iCol) * 1
         iRow = iRow + 1
         iCol = 1
      Loop
   Close
End Sub

     Code eingefügt mit Syntaxhighlighter 2.5

Gruß Sepp
Ein kluger Mann macht nicht alle Fehler selbst.
Er lässt auch anderen eine Chance.

(Sir Winston Churchill)
Anzeige
AW: das komma soll weg
22.02.2004 22:32:45
sLy
dankeschön :)
Danke für die Rückmeldung! o.T.
22.02.2004 23:20:09
Josef Ehrensberger
Gruß Sepp
Ein kluger Mann macht nicht alle Fehler selbst.
Er lässt auch anderen eine Chance.

(Sir Winston Churchill)

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige