Hello Sameki121,
This macro may be what you want. It lets you choose the text file to open, the worksheet you want the output on, and the range where the output is to start. The header is copied only once.
Sub ImportGPSData()
Dim Data As Variant
Dim Filename As String
Dim FSO As Object
Dim Line As Long
Dim N As Long
Dim R As Long
Dim Rng As Range
Dim TextFile As Object
Dim Wks As Worksheet
Set Wks = Worksheets("Sheet1")
Set Rng = Wks.Range("A1:H1")
Filename = Application.GetOpenFilename("Text Files (*.txt),*.txt")
If Filename = "False" Then Exit Sub
Set FSO = CreateObject("Scripting.FileSystemObject")
Set TextFile = FSO.OpenTextFile(Filename, 1, False, 0)
Do While Not TextFile.AtEndOfStream
Data = TextFile.ReadLine
Line = Line + 1
If Line = 1 Then Data = Mid(Data, 7, Len(Data) - 7)
If Line > 2 And (Line And 1) Then
' If line number is odd then don't copy it.
Else
Rng.Offset(R, 0).Value = Split(Data, ",")
R = R + 1
End If
Loop
TextFile.Close
End Sub
Bookmarks