Hallo,
ich möchte die Textdatei in der Tabelle2 ab der Zelle C2 einfügen. Es sollen
10 Zeilen oberhalb und 2 Spalten links neben den eingefügten Daten frei bleiben.
Wer kann helfen den VBA Code so zu verändern ?
Danke im voraus
Peter
Sub AusTextDatei()
Application.ScreenUpdating = False
'Import in Exceltabelle
Dim intRow As Integer, intCol As Integer
Dim strTxt As String, sFile As String
Dim ZSh As Worksheet
Set ZSh = Worksheets("Tabelle2")
ZSh.Range("A1").CurrentRegion.ClearContents
'----------------Speicherort der Textdatei---------------------
sFile = "C:\Users\Master\Documents\Testordner\TxtTest.txt"
If Dir(sFile) = "" Then
Beep
MsgBox "Die Textdatei " & sFile & " existiert nicht!", vbCritical
Exit Sub
End If
Close
Open sFile For Input As #1
Do Until EOF(1)
intRow = intRow + 1
intCol = 0
Line Input #1, strTxt
Do Until InStr(strTxt, ",") = 0
intCol = intCol + 1
ZSh.Cells(intRow, intCol) = Left(strTxt, InStr(strTxt, ",") - 1)
strTxt = Right(strTxt, Len(strTxt) - InStr(strTxt, ","))
Loop
ZSh.Cells(intRow, intCol + 1) = strTxt
Loop
Close
End Sub