AW: Fehlermeldung bei Daten extern speichern
25.11.2006 20:16:40
Erich
Hallo Harald,
Join erwartet ein eindimensionales Datenfeld als ersten Parameter, vntTemp ist aber zweidimensional
(kannst du dir im Überwachungsfenster ansehen).
So läuft es jedenfalls: (Das Trennzeichen kann man dann natürlich auch gleich in der Schelife anhängen.)
Sub DatenExternSpeichern1(Wks As Worksheet)
Dim strRng() As String, R As Long, strOut As String, iCols As Integer, ii As Integer
With Wks
iCols = .Cells(3, 255).End(xlToLeft).Column
ReDim strRng(iCols - 1)
Open ThisWorkbook.Path & "\" & .Name & ".txt" For Output As #1
For R = 3 To .Cells(65536, 1).End(xlUp).Row
strOut = ""
For ii = 1 To iCols
strRng(ii - 1) = .Cells(R, ii)
Next ii
strOut = Join(strRng, "|")
Print #1, strOut
Next R
Close #1
End With
End Sub
'oder so:
Sub DatenExternSpeichern2(Wks As Worksheet)
Dim vntRng, strRng() As String, R As Long, strOut As String, iCols As Integer, ii As Integer
With Wks
iCols = .Cells(3, 255).End(xlToLeft).Column
ReDim strRng(iCols - 1)
Open ThisWorkbook.Path & "\" & .Name & ".txt" For Output As #1
For R = 3 To .Cells(65536, 1).End(xlUp).Row
strOut = ""
vntRng = .Range(.Cells(R, 1), .Cells(R, iCols))
For ii = 1 To iCols
strRng(ii - 1) = vntRng(1, ii)
Next ii
strOut = Join(strRng, "|")
Print #1, strOut
Next R
Close #1
End With
End Sub
Rückmeldung wäre nett! - Grüße von Erich aus Kamp-Lintfort