Attachment 4802
From the picture above we can see some information in a .txt file. In this txt file there are 1000 over lines and most of them I not needed. So what I want my macro to do is that, once I opened the .txt file it should
1. Look for the word “RESISTOR” and extract all the information that is written after the word RESISTOR”, and
2. Stops once it see the word “NODES”, which means all the information after the word “NODES” should not be included on my spreadsheet when I open the file.
Below is a sample of how my spreadsheet should look like once I click the button and open the txt file.
http://www.iimmgg.com/image/205d30e1...1686fbd097afd3
This is the codes I used to open the txt file, after that I don’t know how to continue.
Private Sub CommandButton1_Click()
On Error GoTo ErrorHandler
myFile = Application.GetOpenFilename("Text Files,*.txt")
Workbooks.OpenText Filename:= _
myFile, Origin _
:=xlWindows, StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array _
(4, 1), Array(10, 1), Array(26, 1), Array(27, 1), Array(50, 1), Array(58, 1)), _
TrailingMinusNumbers:=True
ActiveSheet.Move After:=Workbooks("retriveFile.xls").Sheets(1)
ActiveWindow.WindowState = xlMaximized
Exit Sub
ErrorHandler:
MsgBox "Plese select a file", vbInformation, "unable to continue" '& Err.Number & vbCrLf & vbCrLf & Err.Description
End Sub