export -> import
27.12.2003 16:32:26
Chris
ich brauche unbedingt Eure Hilfe. Ich habe 2 Makros eins zum exportieren und eins zum importieren:
Sub TextImport()
Dim intRow As Integer, intCol As Integer
Dim strTxt As String
Close
Open "C:\Pfad\Datenbank" For Input As #1
Do Until EOF(1)
intRow = intRow + 1
Input #1, strTxt
strTxt = Application.Trim(strTxt)
strTxt = Application.Clean(strTxt)
Do Until InStr(strTxt, ";") = 0
intCol = intCol + 1
Cells(intRow, intCol) = Left(strTxt, InStr(strTxt, ";") - 1)
strTxt = Right(strTxt, Len(strTxt) - InStr(strTxt, ";"))
Loop
intCol = intCol + 1
Cells(intRow, intCol) = strTxt
intCol = 0
Loop
Close
End Sub
Sub AlsTextSpeichern()
Dim TB As Worksheet, Dateinummer%
Dim z%, s%, TMP$
exportfile = "C:\Pfad\Datenbank"
Dateinummer = FreeFile
Set TB = ThisWorkbook.Worksheets(1)
Open exportfile For Output As #Dateinummer
For z = 1 To TB.UsedRange.Rows.Count
If Cells(z, 2).Value = Text Then SL = 10 Else SL = 6
For s = 1 To TB.UsedRange.Columns.Count
TMP = TMP & CStr(TB.Cells(z, s).Text) & ";"
Next s
TMP = Left(TMP, Len(TMP) - 1)
Print #Dateinummer, TMP
TMP = ""
Next z
Close #Dateinummer
End Sub
Das Problem ist, wenn ich einen neuen Datensatz abspeichern möchte wird der letzte überschrieben. Meine Daten werden immer in A1 bis BD1 geschrieben. Ich bin nicht so der Excelspezi, aber wäre es nicht sinnvoll, bei export eine neu Zeile über der aktuellen einfügen zu lassen ???? Die Daten hohle ich mit der Funktion =Tabelle!A1 usw. in die angehende Datenbank. Es wäre klasse, wenn ihr mir helfen könntet.
Chris