Paras,
Assuming you wanted the text to be put into Cell A1 and down of the activesheet (and only in column A), you can use the following code:
Sub ExtractTextMacro_for_Paras()
Dim strPath As String: strPath = Application.GetOpenFilename("Text Files (*.txt), *.txt)")
If strPath = "False" Then Exit Sub
Application.ScreenUpdating = False
Dim DataStart As Boolean: DataStart = False
Dim DataEnd As Boolean: DataEnd = False
Dim strLine As String
Dim arrLine() As String, LineIndex As Long
Close #1: Open strPath For Input As #1
While Not EOF(1) And DataEnd = False
Line Input #1, strLine
If strLine = "SKCORD 1" Then DataStart = True
If strLine = "ASPFN SAME" Then DataEnd = True
If DataStart = True And DataEnd = False Then
LineIndex = LineIndex + 1
ReDim Preserve arrLine(1 To LineIndex)
arrLine(LineIndex) = strLine
End If
Wend
Close #1
If LineIndex > 1 Then
ReDim Preserve arrLine(1 To LineIndex - 1)
ActiveSheet.[A1].Resize(LineIndex - 1, 1).Value = WorksheetFunction.Transpose(arrLine)
End If
Application.ScreenUpdating = True
End Sub
Hope that helps,
~tigeravatar
Bookmarks